Commit Graph

136 Commits

Author SHA1 Message Date
Giuseppe Bilotta d566382a98 util: fix comment typo
Undefining the NDEBUG is relevant for release build, as they are the
ones that set it.

[Emil Velikov: split from previous patch]
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-12-04 14:06:41 +00:00
Jose Fonseca 56aff6bb4e Remove Sun CC specific code.
Reviewed-by: Matt Turner <mattst88@gmail.com>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2015-12-02 07:51:04 +00:00
Neil Roberts bc2470d5d3 util: Tiny optimisation for the linear→srgb conversion
When converting 0.0 it would be nice if it didn't do any arithmetic.

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
2015-11-27 10:55:22 +01:00
Matt Turner d956335a0b util: Include assert.h in macros.h. 2015-11-24 10:05:32 -08:00
Matt Turner fafbf994cf util: Include <stdbool.h> in debug.h. 2015-11-24 10:05:32 -08:00
Rob Clark d278e31459 util: move brw_env_var_as_boolean() to util
Kind of a handy function.  And I'll want it available outside of i965
for common nir-pass helpers.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
Reviewed-by: Nicolai Hähnle <nhaehnle@gmail.com>
2015-11-24 10:02:55 -05:00
Matt Turner 238877207e ralloc: Set *start in ralloc_vasprintf_rewrite_tail() if str is NULL.
We were leaving it undefined, even though we were writing a string to
*str.

Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2015-11-12 11:00:10 -08:00
Eduardo Lima Mitev fb3b5669ce util: Add list_is_singular() helper function
Returns whether the list has exactly one element.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-11-10 21:13:35 +01:00
Rob Clark 183db3a645 glsl: move half<->float convertion to util
Needed in NIR too, so move out of mesa/main/imports.c

Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
Reviewed-by: Emil Velikov <emil.velikov@collabora.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-10-16 19:33:37 -04:00
Kristian Høgsberg Kristensen 04158fb0f6 util: Move DRI parse_debug_string() to util
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 <topi.pohjolainen@intel.com>
Signed-off-by: Kristian Høgsberg Kristensen <krh@bitplanet.net>
2015-10-08 12:13:31 -07:00
Samuel Iglesias Gonsalvez f3afcbecc6 util: use strnlen() in strndup() implementations
If the string being copied is not NULL-terminated the result of
strlen() is undefined.

Signed-off-by: Samuel Iglesias Gonsalvez <siglesias@igalia.com>
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Jose Fonseca <jfonseca@vmware.com>
2015-09-30 08:13:07 +02:00
Jose Fonseca 952366a60e util: Fix strndup prototype on C++.
Trivial.
2015-09-29 16:01:56 +01:00
Samuel Iglesias Gonsalvez bea66d22f2 util: implement strndup for WIN32
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 <jfonseca@vmware.com>
2015-09-29 10:03:47 +02:00
Emil Velikov d65bd7a7be util: automake: rework the format_srgb.c rule
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 <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com> (v1)
2015-09-09 12:48:09 +01:00
Ilia Mirkin ae535cb0bf util: make mesa-sha1.c completely empty when there are no SHA1 impls
My earlier attempt to fix this missed the fact that there was a #else
clause that assumes that you have openssh. This moves the whole thing
under #ifdef HAVE_SHA1 which should avoid this issue.

Fixes: 13bfa5201 (util: always include sha1 into the build)
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=91898
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@gmail.com>
2015-09-07 00:18:12 -04:00
Ilia Mirkin 13bfa52011 util: always include sha1 into the build
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: 04e201d0c0 ("mesa: change 'SHADER_SUBST' facility to work with env variables")
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Dave Airlie <airlied@gmail.com>
2015-09-06 16:11:24 -04:00
Roland Scheidegger 2b40a144b7 util/ra: (trivial) fix c99 loop variable initialization
Fails with old msvc otherwise.
2015-08-19 04:17:49 +02:00
Roland Scheidegger 3f797ef0c0 util: (trivial) include c99_math.h in rounding.h
Needed for rint/rintf.
2015-08-19 04:17:36 +02:00
Jason Ekstrand f01bdb0484 util/ra: Make allocating conflict lists optional
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 <eric@anholt.net>
2015-08-18 17:48:53 -07:00
Jason Ekstrand 9b49284c22 util/ra: Add a function for making all conflicts on a register transitive
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-08-18 17:48:45 -07:00
Jason Ekstrand 7c8e53f1be util/bitset: Add a BITSET_FOREACH_SET macro
Reviewed-by: Eric Anholt <eric@anholt.net>
2015-08-18 17:48:28 -07:00
Jason Ekstrand bdcc8f3230 ra: Delete the conflict lists in ra_set_finalize
They are never used after the set is finalized so there's no reason to keep
them around.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-08-10 11:58:58 -07:00
Jason Ekstrand 7539ac7fe2 ra: Refactor ra_set_finalize
All this commit does is change an early return to an if with an else
clause.

Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-08-10 11:58:45 -07:00
Jose Fonseca 1eaa29cb30 util: Use LONG_MAX instead of LONG_BIT.
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 <sroland@vmware.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-08-10 00:08:55 +01:00
Jose Fonseca 497a22a727 scons: Build roundevent_test.
Reviewed-by: Roland Scheidegger <sroland@vmware.co>
2015-08-10 00:07:27 +01:00
Jose Fonseca 21ccdbdb5d util: Cope with LONG_BIT not being defined on Windows.
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.
2015-08-09 11:32:43 +01:00
Jose Fonseca 512aa0647f util: Rename PURE to ATTRIBUTE_PURE.
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 <brianp@vmware.com>
2015-08-09 11:32:43 +01:00
Matt Turner 680de24545 util: Use SSE intrinsics in _mesa_lroundeven{f,}.
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 <sroland@vmware.com>
2015-08-04 10:33:13 -07:00
Matt Turner 594fc0f859 mesa: Replace F_TO_I() with _mesa_lroundevenf().
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 <sroland@vmware.com>
2015-08-03 09:24:51 -07:00
Matt Turner b568a5f6a8 util: Avoid double promotion.
Reviewed-by: Iago Toral Quiroga <itoral@igalia.com>
2015-07-29 09:34:52 -07:00
Eric Anholt be1f49bda9 mesa: Detect and provide macros for function attributes pure and const.
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 <kenneth@whitecape.org> (v1)
2015-07-17 12:25:54 -07:00
Matt Turner a2dde3a8da util: Don't link to SHA1 library if shader-cache is disabled.
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2015-07-09 15:49:02 -07:00
Kenneth Graunke 128de6f6d7 mesa: Add a MUST_CHECK macro for __attribute__((warn_unused_result)).
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 <kenneth@whitecape.org>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Matt Turner <mattst88@gmail.com>
2015-07-06 13:40:16 -07:00
Erik Faye-Lund e566e5203a mesa/main: free locale at exit
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 <kusmabite@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2015-06-29 09:06:40 -07:00
Erik Faye-Lund c61bc6ed84 util: port _mesa_strto[df] to C
_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 <kusmabite@gmail.com>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Brian Paul <brianp@vmware.com>
2015-06-29 09:06:40 -07:00
Rob Clark c79b2e626c util/list: add list_first/last_entry
I need an easier way to get at head/tail in ir3.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
2015-06-21 07:52:36 -04:00
Jason Ekstrand 2c2cd368aa util/list: Add a list validation function
Acked-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
2015-05-08 17:16:13 -07:00
Jason Ekstrand addcf41066 util/list: Add list_empty and list_length functions
v2: Don't use C99 when iterating over the list

Acked-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
2015-05-08 17:16:13 -07:00
Jason Ekstrand b31d8983ba util/list: Add C99-based iterator macros
v2: Use LIST_ENTRY instead of container_of in iterators

Acked-by: Connor Abbott <cwabbott0@gmail.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
2015-05-08 17:16:13 -07:00
Jason Ekstrand 7a30668ad6 util: Move gallium's linked list to util
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 <cwabbott0@gmail.com>
Reviewed-by: Rob Clark <robclark@freedesktop.org>
2015-05-08 17:16:13 -07:00
Axel Davy 64880d073a util/macros: Move DIV_ROUND_UP to util/macros.h
Move DIV_ROUND_UP to a shared location accessible everywhere

Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Axel Davy <axel.davy@ens.fr>
2015-04-29 08:28:10 +02:00
Chih-Wei Huang b0e33c2256 android: fix the building rules for Android 5.0
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 <cwhuang@linux.org.tw>
2015-04-22 15:53:35 +01:00
Emil Velikov 94cab35ee9 android: add gallium dirs to more places in the tree
Similar to e8c5cbfd921(mesa: Add gallium include dirs to more parts of
the tree.)

Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chih-Wei Huang <cwhuang@linux.org.tw>
2015-04-22 14:36:25 +01:00
Emil Velikov 6fb8017866 android: add $(mesa_top)/src include to the whole of mesa
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" <mesa-stable@lists.freedesktop.org>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Chih-Wei Huang <cwhuang@linux.org.tw>
2015-04-22 14:26:22 +01:00
Chih-Wei Huang 6c2c5f74a2 util: android: optimize the rules to generate format_srgb.c
Signed-off-by: Chih-Wei Huang <cwhuang@linux.org.tw>
Reviewed-by: Emil Velikov <emil.l.velikov@gmail.com>
2015-04-22 14:24:22 +01:00
Jose Fonseca 978753e843 util/ralloc: Fix `extern "C"` usage.
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
2015-04-13 12:03:26 +01:00
Kenneth Graunke 33f0f68d59 ralloc: Implement a new ralloc_adopt() API.
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 <kenneth@whitecape.org>
Reviewed-by: Jason Ekstrand <jason.ekstrand@intel.com>
2015-04-02 14:19:41 -07:00
Jose Fonseca 25d6cdd2ff util/u_atomic: Ignore warnings interlocked accesses.
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 <brianp@vmware.com>
2015-03-25 10:42:48 +00:00
Matt Turner 036e347f3c util: Optimize _mesa_roundeven with SSE 4.1.
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 <cworth@cworth.org>
2015-03-18 21:06:26 -07:00
Matt Turner 5de86102f9 util: Add a roundeven test.
Reviewed-by: Carl Worth <cworth@cworth.org>
2015-03-18 21:06:26 -07:00