summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* 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
* util: use GCC atomic intrinsics with explicit memory modelNicolai Hähnle2016-10-051-0/+21
| | | | | | | | | | | | | | | | | | | | | | | | This is motivated by the fact that p_atomic_read and p_atomic_set may somewhat surprisingly not do the right thing in the old version: while stores and loads are de facto atomic at least on x86, the compiler may apply re-ordering and speculation quite liberally. Basically, the old version uses the "relaxed" memory ordering. The new ordering always uses acquire/release ordering. This is the strongest possible memory ordering that doesn't require additional fence instructions on x86. (And the only stronger ordering is "sequentially consistent", which is usually more than you need anyway.) I would feel more comfortable if p_atomic_set/read in the old implementation were at least using volatile loads and stores, but I don't see a way to get there without typeof (which we cannot use here since the code is compiled with -std=c99). Eventually, we should really just move to something that is based on the atomics in C11 / C++11. Acked-by: Marek Olšák <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: remove Sun C Compiler supportTimothy Arceri2016-09-231-1/+1
| | | | | | Support for this compiler was dropped in 51564f04b77e6 Acked-by: Edward O'Callaghan <[email protected]>
* u_endian: add android to glibc clauseDave Airlie2016-09-131-1/+1
| | | | Tested-by: Mauro Rossi <[email protected]>
* mesa/glsl: Move string_to_uint_map into the util folderThomas Helland2016-09-123-0/+221
| | | | | | | | | | 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: Move hash_table_call_foreach to util hash tableThomas Helland2016-09-121-0/+13
| | | | | | | | | | It is included through the util/hash_table include in the program hash_table, so this should be safe. This will be needed when we start converting each use of the program_hash_table, as some places need this function. Signed-off-by: Thomas Helland <[email protected]> Reviewed-by: Timothy Arceri <[email protected]>
* util: (trivial) add <stdint.h> include to slab.cRoland Scheidegger2016-09-061-0/+1
| | | | should fix "src/util/slab.c:57:13: error: ‘uint8_t’ undeclared"
* util: import the slab allocator from galliumMarek Olšák2016-09-063-0/+244
| | | | There are also some cosmetic changes.
* gallium/util: move endian detect into a separate fileDave Airlie2016-09-062-1/+71
| | | | | | | | 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: add assert that key cannot be NULL on insertionTapani Pälli2016-08-221-0/+2
| | | | | | Signed-off-by: Tapani Pälli <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]> Reviewed-by: Eric Anholt <[email protected]>
* mesa: Fix uf10_to_f32() scale factor in the E == 0 and M != 0 case.Kenneth Graunke2016-08-171-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GL_EXT_packed_float, 2.1.B Unsigned 10-Bit Floating-Point Numbers: 0.0, if E == 0 and M == 0, 2^-14 * (M / 32), if E == 0 and M != 0, 2^(E-15) * (1 + M/32), if 0 < E < 31, INF, if E == 31 and M == 0, or NaN, if E == 31 and M != 0, In the second case (E == 0 and M != 0), we were multiplying the mantissa by 2^-20, when we should have been multiplying by 2^-19 (which is 2^(-14 + -5), or 2^-14 * 2^-5, or 2^-14 / 32). The previous section defines the formula for 11-bit numbers, which is: 2^-14 * (M / 64), if E == 0 and M != 0, In other words, we had accidentally copy and pasted the 11-bit code to the 10-bit case, and neglected to change the exponent. Fixes dEQP-GLES3.functional.pbo.renderbuffer.r11f_g11f_b10f_triangles when run with surface dimensions of 1536x1152 or 1920x1080. Cc: [email protected] References: https://code.google.com/p/chrome-os-partner/issues/detail?id=56244 Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Stephane Marchesin <[email protected]> Reviewed-by: Antia Puentes <[email protected]>
* util: try to use SSE instructions with MSVC and 32-bit gccBrian Paul2016-08-171-3/+4
| | | | | | | | | | | | | The lrint() and lrintf() functions are pretty slow and make some texture transfers very inefficient. This patch makes a better effort at using those intrisics for 32-bit gcc and MSVC. Note, this patch doesn't address the use of SSE4.1 with MSVC. v2: get rid of the ROUND_WITH_SSE symbol, per Matt. Reviewed-by: José Fonseca <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* util: Use win32 intrinsics for util_last_bit if present.Mathias Fröhlich2016-08-101-0/+12
| | | | | | | | | v2: Split into two patches. v3: Fix off by one problem. Signed-off-by: Mathias Fröhlich <[email protected]> Reviewed-by: Brian Paul <[email protected]> Tested-by: Brian Paul <[email protected]>
* util: Move _mesa_fsl/util_last_bit into util/bitscan.hMathias Fröhlich2016-08-091-0/+68
| | | | | | | | | | | As requested with the initial creation of util/bitscan.h now move other bitscan related functions into util. v2: Split into two patches. Signed-off-by: Mathias Fröhlich <[email protected]> Tested-by: Brian Paul <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util/r11g11b10f: Whitespace cleanupsJason Ekstrand2016-08-051-14/+7
| | | | | Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util/format: Use explicitly sized typesJason Ekstrand2016-08-052-6/+8
| | | | | | | | | Both the rgb9e5 and r11g11b10 formats are defined based on how they are packed into a 32-bit integer. It makes sense that the functions that manipulate them take an explicitly sized type. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util/rgb9e5: Get rid of the float754 unionJason Ekstrand2016-08-051-42/+27
| | | | | | | | | | | There are a number of reasons for this refactor. First, format_rgb9e5.h is not something that a user would expect to define such a generic union. Second, defining it requires checking for endianness which is ugly. Third, 90% of what we were doing with the union was float <-> uint32_t bitcasts and the remaining 10% can be done with a sinmple left-shift by 23. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util/format_rgb9e5: Get rid of the rgb9e5 unionJason Ekstrand2016-08-051-32/+6
| | | | | | | | | The rgb9e5 format is a packed format defined in terms of slicing up a single 32-bit value. The bitfields are far more confusing than simple shifts and require that we check the endianness. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* util: Move format_r11g11b10f.h to src/utilJason Ekstrand2016-08-052-0/+233
| | | | | | | 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-052-0/+162
| | | | | | | It's used from both mesa main and gallium. Signed-off-by: Jason Ekstrand <[email protected]> Reviewed-by: Roland Scheidegger <[email protected]>
* list: fix list_replace() for empty listsRob Clark2016-07-061-4/+10
| | | | | | | | | Before, it would happily copy list_head next/prev (ie. pointer to the *from* list_head), leaving things in a confused state and causing much mayhem. Signed-off-by: Rob Clark <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* mesa/gallium: Move u_bit_scan{,64} from gallium to util.Mathias Fröhlich2016-06-143-0/+235
| | | | | | | | | | | | | | | 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]>
* mesa: Add .gitignore entries for make check binariesKristian Høgsberg Kristensen2016-05-252-0/+2
| | | | | Signed-off-by: Kristian Høgsberg Kristensen <[email protected]> Acked-by: Matt Turner <[email protected]>
* util: Add ATTRIBUTE_RETURNS_NONNULL.Matt Turner2016-05-161-0/+6
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* util/ralloc: Remove double zero'ing of rzalloc buffersJordan Justen2016-05-101-9/+12
| | | | | | | | | | | | | | | | | | | | | | Juha-Pekka found this back in May 2015: <[email protected]> From the discussion, obviously it would be preferable to make ralloc_size no longer return zeroed memory, but Juha-Pekka found that it would break Mesa. In <[email protected]>, Juha-Pekka mentioned that patches exist to fix i965 when ralloc_size is fixed to not zero memory, but the patches have not made their way to mesa-dev yet. For now, let's stop doing the double zeroing of rzalloc buffers. v2: * Move ralloc_size code to rzalloc_size, and add a comment as suggested by Ken. Signed-off-by: Jordan Justen <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* st/glsl_to_tgsi: reduce stack explosion in recursive expression visitorNicolai Hähnle2016-04-291-0/+6
| | | | | | | | | | | | | | | | | | | | | | | | In optimized builds, visit(ir_expression *) experiences inlining with gcc that leads the function to have a roughly 32KB stack frame. This is a problem given that the function is called recursively. In non-optimized builds, the stack frame is much smaller, hence one gets crashes that happen only in optimized builds. Arguably there is a compiler bug or at least severe misfeature here. In any case, the easy thing to do for now seems to be moving the bulk of the non-recursive code into a separate function. This is sufficient to convince my version of gcc not to blow up the stack frame of the recursive part. Just to be sure, add the gcc-specific noinline attribute to prevent this bug from reoccuring if inliner heuristics change. v2: put ATTRIBUTE_NOINLINE into macros.h Cc: "11.1 11.2" <[email protected]> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95133 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=95026 Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=92850 Reviewed-by: Ilia Mirkin <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* scons: Move fallback HAVE_* definitions to headers.Jose Fonseca2016-04-261-0/+2
| | | | | | | | | | | | | | | | | | These were being defined in SCons, but it's not practical: - we actually need to include Gallium headers from external source trees, with completely disjoint build infrastructure, and it's unsustainable to replicate the HAVE_xxx checks or even hard-coded defines across everywhere. - checking compiler version via command line doesn't really work due to Clang essentially being like a cameleon which can fake either GCC or MSVC There's no change for autoconf. Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util: add MAYBE_UNUSED for config dependent variablesGrazvydas Ignotas2016-04-251-0/+2
| | | | | | | | | | | | | | | | | This is mostly for variables that are only used in asserts and cause unused-but-set-variable warnings in release builds. Could just use UNUSED directly, but MAYBE_UNUSED should be less confusing and is similar to what the Linux kernel has. And yes __attribute__((unused)) can be used on variables on both GCC 4.2 (oldest supported by mesa) and clang 3.0 (just some random old version, not sure what's the minimum for mesa). Signed-off-by: Grazvydas Ignotas <[email protected]> Reviewed-by: Francisco Jerez <[email protected]> Reviewed-by: Chad Versace <[email protected]> Reviewed-by: Ian Romanick <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: Fix warning of invalid return valueChad Versace2016-04-151-1/+2
| | | | | | _mesa_libgcrypt_init() returns NULL, but its return type is void. Reviewed-by: Mark Janes <[email protected]>
* util/list: Add list splicing functionsJason Ekstrand2016-04-151-0/+22
| | | | | | | | | This adds functions for splicing one list into another. These have more-or-less the same API as the kernel list splicing functions. The implementation, however, was stolen from the Wayland list implementation. Reviewed-by: Mark Janes <[email protected]> Reviewed-by: Rob Clark <[email protected]>