summaryrefslogtreecommitdiffstats
path: root/src/util
Commit message (Collapse)AuthorAgeFilesLines
* util: automake: rework the format_srgb.c ruleEmil Velikov2015-09-111-2/+4
| | | | | | | | | | | | | | | A handful of changes/cleanups paving the way to bmake support: - Remove optional $(srcdir)/ prefix for files in the prereq list. - Drop the space after the AM_V_GEN variable. - Using $< in a non-suffix rule is a GNU make idiom. - Use $(@D) over $(dir $@). The latter is a POSIX standard. v2: Cosmetic tweaks in the commit summary. Cc: 11.0 <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Matt Turner <[email protected]> (v1) (cherry picked from commit d65bd7a7be48d7805f68cd45218794f3e4590408)
* Revert SHA1 additions.Matt Turner2015-08-225-385/+0
| | | | | | | | | | | | | | The shader-cache isn't finished, so the configure checks are a bit premature and will only stand to confuse users of Mesa 11.0. This is a squash of the follow four reverts: Revert "Rename sha1.c and sha1.h to mesa-sha1.c and mesa-sha1.h" Revert "configure: Add machinery for --enable-shader-cache (and --disable-shader-cache)" Revert "sha1: Fix gcry_md_hd_t typo." Revert "mesa: Add mesa SHA-1 functions" Reviewed-by: Carl Worth <[email protected]>
* util/ra: (trivial) fix c99 loop variable initializationRoland Scheidegger2015-08-191-7/+8
| | | | Fails with old msvc otherwise.
* util: (trivial) include c99_math.h in rounding.hRoland Scheidegger2015-08-191-2/+1
| | | | Needed for rint/rintf.
* util/ra: Make allocating conflict lists optionalJason Ekstrand2015-08-182-10/+19
| | | | | | | | | Since i965 is now using make_reg_conflicts_transitive and doesn't need q-value computations, they are disabled on i965. They are enabled everywhere else so that they get the old behavior. This reduces the time spent in eglInitialize() on BDW by around 10-15%. Reviewed-by: Eric Anholt <[email protected]>
* util/ra: Add a function for making all conflicts on a register transitiveJason Ekstrand2015-08-182-0/+24
| | | | Reviewed-by: Eric Anholt <[email protected]>
* util/bitset: Add a BITSET_FOREACH_SET macroJason Ekstrand2015-08-181-0/+36
| | | | Reviewed-by: Eric Anholt <[email protected]>
* ra: Delete the conflict lists in ra_set_finalizeJason Ekstrand2015-08-101-0/+5
| | | | | | | They are never used after the set is finalized so there's no reason to keep them around. Reviewed-by: Matt Turner <[email protected]>
* ra: Refactor ra_set_finalizeJason Ekstrand2015-08-101-26/+25
| | | | | | | All this commit does is change an early return to an if with an else clause. Reviewed-by: Matt Turner <[email protected]>
* util: Use LONG_MAX instead of LONG_BIT.Jose Fonseca2015-08-101-6/+7
| | | | | | | | | | | More portable. Based on Roland Scheidegger's idea. Tested with roundevent_test on Linux, MinGW, and MSVC. https://bugs.freedesktop.org/show_bug.cgi?id=91591 Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* scons: Build roundevent_test.Jose Fonseca2015-08-102-0/+9
| | | | Reviewed-by: Roland Scheidegger <[email protected]>
* util: Cope with LONG_BIT not being defined on Windows.Jose Fonseca2015-08-091-2/+6
| | | | | | | | | | | | Neither MSVC nor MinGW defines LONG_BIT. For MSVC this was not a problem as it doesn't define __x86_64__ macro (it's GCC specific.) However on Windows long type is guaranteed to be 32bits. Also add an #error, as GCC will just warn, not throw any error, when no value is returned. Trivial.
* util: Rename PURE to ATTRIBUTE_PURE.Jose Fonseca2015-08-091-2/+2
| | | | | | | | | To avoid collission with windows.h's PURE macro. We could consider eventually renaming to __pure, but that would require further care, so it's left to the future. Reviewed-by: Brian Paul <[email protected]>
* util: Use SSE intrinsics in _mesa_lroundeven{f,}.Matt Turner2015-08-041-0/+22
| | | | | | | | | | | | | | gcc actually generates this for us now that we use -fno-math-errno (which is weird, since lrintf()/lrint() don't set errno) but clang still does not. Presumably helps MSVC as well. Reduced .text size by 8.5k with gcc before -fno-math-errno. text data bss dec hex filename 4935850 195136 26192 5157178 4eb13a i965_dri.so before 4927225 195128 26192 5148545 4e8f81 i965_dri.so after Reviewed-by: Roland Scheidegger <[email protected]>
* mesa: Replace F_TO_I() with _mesa_lroundevenf().Matt Turner2015-08-031-0/+25
| | | | | | | | | | | I'm not sure what the true meaning of "The rounding mode may vary." is, but it is the case that the IROUND() path rounds differently than the other paths (and does it wrong, at that). Like _mesa_roundeven{f,}(), just add an use _mesa_lroundeven{f,}() that has known semantics. Reviewed-by: Roland Scheidegger <[email protected]>
* util: Avoid double promotion.Matt Turner2015-07-291-1/+1
| | | | Reviewed-by: Iago Toral Quiroga <[email protected]>
* mesa: Detect and provide macros for function attributes pure and const.Eric Anholt2015-07-171-0/+20
| | | | | | | | | | | | | These are really useful hints to the compiler in the absence of link-time optimization, and I'm going to use them in VC4. I've made the const attribute be ATTRIBUTE_CONST unlike other function attributes, because we have other things in the tree #defining CONST for their own unrelated purposes. v2: Alphabetize. Reviewed-by: Kenneth Graunke <[email protected]> (v1)
* util: Don't link to SHA1 library if shader-cache is disabled.Matt Turner2015-07-091-1/+1
| | | | Reviewed-by: Kenneth Graunke <[email protected]>
* mesa: Add a MUST_CHECK macro for __attribute__((warn_unused_result)).Kenneth Graunke2015-07-061-0/+6
| | | | | | | | | In the kernel, this is called __must_check; all our attribute macros in Mesa appear to be uppercase, so I went with that. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Chris Wilson <[email protected]> Reviewed-by: Matt Turner <[email protected]>
* mesa/main: free locale at exitErik Faye-Lund2015-06-292-0/+11
| | | | | | | | | In order to save a small leak if mesa is continously loaded and unloaded, let's free the locale when the shared object is unloaded. Signed-off-by: Erik Faye-Lund <[email protected]> Reviewed-by: Matt Turner <[email protected]> Reviewed-by: Brian Paul <[email protected]>
* util: port _mesa_strto[df] to CErik Faye-Lund2015-06-293-7/+12
| | | | | | | | | | | | | _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/list: add list_first/last_entryRob Clark2015-06-211-0/+7
| | | | | | I need an easier way to get at head/tail in ir3. Signed-off-by: Rob Clark <[email protected]>
* util/list: Add a list validation functionJason Ekstrand2015-05-081-0/+9
| | | | | Acked-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* util/list: Add list_empty and list_length functionsJason Ekstrand2015-05-081-0/+15
| | | | | | | v2: Don't use C99 when iterating over the list Acked-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* util/list: Add C99-based iterator macrosJason Ekstrand2015-05-081-0/+34
| | | | | | | v2: Use LIST_ENTRY instead of container_of in iterators Acked-by: Connor Abbott <[email protected]> Reviewed-by: Rob Clark <[email protected]>
* util: Move gallium's linked list to utilJason Ekstrand2015-05-082-0/+147
| | | | | | | | | 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]>
* util/macros: Move DIV_ROUND_UP to util/macros.hAxel Davy2015-04-291-0/+2
| | | | | | | Move DIV_ROUND_UP to a shared location accessible everywhere Reviewed-by: Brian Paul <[email protected]> Signed-off-by: Axel Davy <[email protected]>
* android: fix the building rules for Android 5.0Chih-Wei Huang2015-04-221-2/+2
| | | | | | | | | | | | | | | | | Android 5.0 allows modules to generate source into $OUT/gen, which will then be copied into $OUT/obj and $OUT/obj_$(TARGET_2ND_ARCH) as necessary. Modules will need to change calls to local-intermediates-dir into local-generated-sources-dir. The patch changes local-intermediates-dir into local-generated-sources-dir. If the Android version is less than 5.0, fallback to local-intermediates-dir. The patch also fixes the 64-bit building issue of Android 5.0. v2 [Emil Velikov] - Keep the LOCAL_UNSTRIPPED_PATH variable. Signed-off-by: Chih-Wei Huang <[email protected]>
* android: add gallium dirs to more places in the treeEmil Velikov2015-04-221-2/+6
| | | | | | | | Similar to e8c5cbfd921(mesa: Add gallium include dirs to more parts of the tree.) Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Chih-Wei Huang <[email protected]>
* android: add $(mesa_top)/src include to the whole of mesaEmil Velikov2015-04-221-4/+2
| | | | | | | | | Many parts of mesa already have the include with others depending on it but it's missing. Add it once at the top makefile and be done with it. Cc: "10.4 10.5" <[email protected]> Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Chih-Wei Huang <[email protected]>
* util: android: optimize the rules to generate format_srgb.cChih-Wei Huang2015-04-221-22/+10
| | | | | Signed-off-by: Chih-Wei Huang <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util/ralloc: Fix `extern "C"` usage.Jose Fonseca2015-04-131-4/+4
| | | | | Reviewed-by: Roland Scheidegger <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* ralloc: Implement a new ralloc_adopt() API.Kenneth Graunke2015-04-022-0/+33
| | | | | | | | | | | | | | | | | | | | | ralloc_adopt() reparents all children from one context to another. Conceptually, ralloc_adopt(new_ctx, old_ctx) behaves like this pseudocode: foreach child of old_ctx: ralloc_steal(new_ctx, child) However, ralloc provides no way to iterate over a memory context's children, and ralloc_adopt does this task more efficiently anyway. One potential use of this is to implement a memory-sweeper pass: first, steal all of a context's memory to a temporary context. Then, walk over anything that should be kept, and ralloc_steal it back to the original context. Finally, free the temporary context. This works when the context is something that can't be freed (i.e. an important structure). Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Jason Ekstrand <[email protected]>
* util/u_atomic: Ignore warnings interlocked accesses.Jose Fonseca2015-03-251-0/+5
| | | | | | | | | These are due how we implemented the atomic tests, not the atomic implementation itself. It's also difficult to refactor the code to avoid the warnings due to the use of macros -- the code would be quite hairy. Reviewed-by: Brian Paul <[email protected]>
* util: Optimize _mesa_roundeven with SSE 4.1.Matt Turner2015-03-181-0/+20
| | | | | | | | | | | | The SSE 4.1 ROUND instructions let us implement roundeven directly. Otherwise we assume that the rounding mode has not been modified (as we do in the rest of Mesa) and use rint(). glibc uses the ROUND instruction in rint() after a cpuid check. This patch just lets us inline it directly when we're already building for SSE 4.1. Reviewed-by: Carl Worth <[email protected]>
* util: Add a roundeven test.Matt Turner2015-03-182-1/+143
| | | | Reviewed-by: Carl Worth <[email protected]>
* mesa: Replace _mesa_round_to_even() with _mesa_roundeven().Matt Turner2015-03-182-0/+59
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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]>
* Add macro for unused function attribute.Vinson Lee2015-03-091-0/+6
| | | | | | Suggested-by: Emil Velikov <[email protected]> Signed-off-by: Vinson Lee <[email protected]> Reviewed-by: Emil Velikov <[email protected]>
* util: rework _MSC_VER >= 1200 checksEmil Velikov2015-03-061-5/+3
| | | | | | | | | Replace the _MSC_VER >= 1200 with defined (_MSC_VER) and compact if/else statements. We require MSVC 2008 or later with commit 46110c5d564. Signed-off-by: Emil Velikov <[email protected]> Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Jose Fonseca <[email protected]>
* include: Add helper header to help trap includes inside extern C.José Fonseca2015-03-061-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is just to help repro and fixing these issues with any C++ compiler -- Commiting this will of course wait until all issues are addressed. $ scons src/glsl/ scons: Reading SConscript files ... Checking for GCC ... yes Checking for Clang ... no Checking for X11 (x11 xext xdamage xfixes glproto >= 1.4.13)... yes Checking for XCB (x11-xcb xcb-glx >= 1.8.1 xcb-dri2 >= 1.8)... yes Checking for XF86VIDMODE (xxf86vm)... yes Checking for DRM (libdrm >= 2.4.38)... yes Checking for UDEV (libudev >= 151)... yes warning: LLVM disabled: not building llvmpipe scons: done reading SConscript files. scons: Building targets ... scons: building associated VariantDir targets: build/linux-x86_64-debug/glsl Compiling src/glsl/ast_array_index.cpp ... Compiling src/glsl/ast_expr.cpp ... Compiling src/glsl/ast_function.cpp ... Compiling src/glsl/ast_to_hir.cpp ... Compiling src/glsl/ast_type.cpp ... Compiling src/glsl/builtin_functions.cpp ... In file included from include/c99_compat.h:28:0, from src/mapi/u_compiler.h:4, from src/mapi/u_thread.h:47, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template<class T> class _IncludeInsideExternCNotPortable; ^ In file included from include/c99_compat.h:28:0, from include/c11/threads.h:38, from src/mapi/u_thread.h:49, from src/mapi/glapi/glapi.h:47, from src/mesa/main/mtypes.h:42, from src/mesa/main/errors.h:47, from src/mesa/main/imports.h:41, from src/mesa/main/core.h:44, from src/glsl/builtin_functions.cpp:58: include/no_extern_c.h:48:1: error: template with C linkage template<class T> class _IncludeInsideExternCNotPortable; ^ Compiling src/glsl/builtin_types.cpp ... Compiling src/glsl/builtin_variables.cpp ... scons: *** [build/linux-x86_64-debug/glsl/builtin_functions.os] Error 1 scons: building terminated because of errors. Reviewed-by: Mark Janes <[email protected]>
* Fix invalid extern "C" around header inclusion.Mark Janes2015-03-052-0/+13
| | | | | | | | | | | System headers may contain C++ declarations, which cannot be given C linkage. For this reason, include statements should never occur inside extern "C". This patch moves the C linkage statements to enclose only the declarations within a single header. Reviewed-by: Jose Fonseca <[email protected]>
* mesa: consolidate PUBLIC macro definitionBrian Paul2015-03-041-0/+23
| | | | | | | Define the macro in src/util/macros.h rather than in two different places. Note that USED isn't actually used anywhere at this time. Reviewed-by: Jose Fonseca <[email protected]>
* scons: Use -Werror MSVC compatibility flags per-directory.Jose Fonseca2015-03-041-0/+2
| | | | | | Matching what we already do with autotools builds. Reviewed-by: Brian Paul <[email protected]>
* configure: Leverage gcc warn options to enable safe use of C99 features ↵Jose Fonseca2015-03-031-1/+2
| | | | | | | | | | | | | | | | | | | | | | | where possible. The main objective of this change is to enable Linux developers to use more of C99 throughout Mesa, with confidence that the portions that need to be built with MSVC -- and only those portions --, stay portable. This is achieved by using the appropriate -Werror= options only on the places they need to be used. Unfortunately we still need MSVC 2008 on a few portions of the code (namely llvmpipe and its dependencies). I hope to eventually eliminate this so that we can use C99 everywhere, but there are technical/logistic challenges (specifically, newer Windows SDKs no longer bundle MSVC, instead require a full installation of Visual Studio, and that has hindered adoption of newer MSVC versions on our build processes.) Thankfully we have more directy control over our OpenGL driver, which is why we're now able to migrate to MSVC 2013 for most of the tree. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* util: replace Elements() with ARRAY_SIZE()Brian Paul2015-03-021-1/+1
| | | | Reviewed-by: Matt Turner <[email protected]>
* Revert "configure: Leverage gcc warn options to enable safe use of C99 ↵Kenneth Graunke2015-02-271-2/+1
| | | | | | | | | features where possible." This reverts commit 79daa510c7a871a33797308a2ccb4b83a067ffbe. I apparently hadn't done a clean build when testing this; it broke the build for Tom, Ben, and myself. We like the idea; let's try a v2.
* configure: Leverage gcc warn options to enable safe use of C99 features ↵Jose Fonseca2015-02-271-1/+2
| | | | | | | | | | | | | | | | | | | | | | | where possible. The main objective of this change is to enable Linux developers to use more of C99 throughout Mesa, with confidence that the portions that need to be built with MSVC -- and only those portions --, stay portable. This is achieved by using the appropriate -Werror= options only on the places they need to be used. Unfortunately we still need MSVC 2008 on a few portions of the code (namely llvmpipe and its dependencies). I hope to eventually eliminate this so that we can use C99 everywhere, but there are technical/logistic challenges (specifically, newer Windows SDKs no longer bundle MSVC, instead require a full installation of Visual Studio, and that has hindered adoption of newer MSVC versions on our build processes.) Thankfully we have more directy control over our OpenGL driver, which is why we're now able to migrate to MSVC 2013 for most of the tree. Reviewed-by: Brian Paul <[email protected]> Reviewed-by: Kenneth Graunke <[email protected]>
* ra: Disable round-robin strategy for optimistically colorable nodes.Francisco Jerez2015-02-231-1/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The round-robin allocation strategy is expected to decrease the amount of false dependencies created by the register allocator and give the post-RA scheduling pass more freedom to move instructions around. On the other hand it has the disadvantage of increasing fragmentation and decreasing the number of equally-colored nearby nodes, what increases the likelihood of failure in presence of optimistically colorable nodes. This patch disables the round-robin strategy for optimistically colorable nodes. These typically arise in situations of high register pressure or for registers with large live intervals, in both cases the task of the instruction scheduler shouldn't be constrained excessively by the dense packing of those nodes, and a spill (or on Intel hardware a fall-back to SIMD8 mode) is invariably worse than a slightly less optimal scheduling. Shader-db results on the i965 driver: total instructions in shared programs: 5488539 -> 5488489 (-0.00%) instructions in affected programs: 1121 -> 1071 (-4.46%) helped: 1 HURT: 0 GAINED: 49 LOST: 5 v2: Re-enable round-robin already for the lowest one of the nodes pushed optimistically onto the sack (Connor). v3: Use UINT_MAX instead of ~0, open-code MIN2 (Jason, Connor). Reviewed-by: Connor Abbott <[email protected]>
* util: Move Mesa's bitset.h to util/.Eric Anholt2015-02-203-1/+101
| | | | Reviewed-by: Jose Fonseca <[email protected]>
* mesa: Add gallium include dirs to more parts of the tree.Eric Anholt2015-02-202-0/+4
| | | | | | v2: Try to patch up the scons bits. Reviewed-by: Jose Fonseca <[email protected]>