diff options
author | Jason Ekstrand <[email protected]> | 2015-12-10 16:58:24 -0800 |
---|---|---|
committer | Jason Ekstrand <[email protected]> | 2015-12-10 18:29:36 -0800 |
commit | d5c9955d3eaa7311e2b2350b6964bae516c7b7b2 (patch) | |
tree | 401e4378dd9909f9010f076d026a77e515170be5 /src/util | |
parent | 8beea9d45b5879ea3dbd9c0e48f0c0eb2451f380 (diff) | |
parent | 78b81be627734ea7fa50ea246c07b0d4a3a1638a (diff) |
Merge remote-tracking branch 'mesa-public/master' into vulkan
This pulls in nir_intrinsic_load/store changes and the switch of all
uniforms in i965 to bytes. This accounts for the Vulkan changes.
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/debug.c | 25 | ||||
-rw-r--r-- | src/util/debug.h | 3 | ||||
-rw-r--r-- | src/util/format_srgb.h | 2 | ||||
-rw-r--r-- | src/util/macros.h | 4 | ||||
-rw-r--r-- | src/util/u_atomic_test.c | 2 |
5 files changed, 33 insertions, 3 deletions
diff --git a/src/util/debug.c b/src/util/debug.c index 3729ce85670..98b1853325d 100644 --- a/src/util/debug.c +++ b/src/util/debug.c @@ -51,3 +51,28 @@ parse_debug_string(const char *debug, return flag; } + +/** + * Reads an environment variable and interprets its value as a boolean. + * + * Recognizes 0/false/no and 1/true/yes. Other values result in the default value. + */ +bool +env_var_as_boolean(const char *var_name, bool default_value) +{ + const char *str = getenv(var_name); + if (str == NULL) + return default_value; + + if (strcmp(str, "1") == 0 || + strcasecmp(str, "true") == 0 || + strcasecmp(str, "yes") == 0) { + return true; + } else if (strcmp(str, "0") == 0 || + strcasecmp(str, "false") == 0 || + strcasecmp(str, "no") == 0) { + return false; + } else { + return default_value; + } +} diff --git a/src/util/debug.h b/src/util/debug.h index 801736aafff..11a8561eb57 100644 --- a/src/util/debug.h +++ b/src/util/debug.h @@ -25,6 +25,7 @@ #define _DEBUG_H #include <stdint.h> +#include <stdbool.h> #ifdef __cplusplus extern "C" { @@ -38,6 +39,8 @@ struct debug_control { uint64_t parse_debug_string(const char *debug, const struct debug_control *control); +bool +env_var_as_boolean(const char *var_name, bool default_value); #ifdef __cplusplus } /* extern C */ diff --git a/src/util/format_srgb.h b/src/util/format_srgb.h index 4a8d73f125f..34b50afe3d1 100644 --- a/src/util/format_srgb.h +++ b/src/util/format_srgb.h @@ -57,7 +57,7 @@ util_format_linear_to_srgb_helper_table[104]; static inline float util_format_linear_to_srgb_float(float cl) { - if (cl < 0.0f) + if (cl <= 0.0f) return 0.0f; else if (cl < 0.0031308f) return 12.92f * cl; diff --git a/src/util/macros.h b/src/util/macros.h index 84e4f182bcf..0c8958feae9 100644 --- a/src/util/macros.h +++ b/src/util/macros.h @@ -24,6 +24,8 @@ #ifndef UTIL_MACROS_H #define UTIL_MACROS_H +#include <assert.h> + /* Compute the size of an array */ #ifndef ARRAY_SIZE # define ARRAY_SIZE(x) (sizeof(x) / sizeof(*(x))) @@ -184,7 +186,7 @@ do { \ * inline a static function that we later use in an alias. - ajax */ #ifndef PUBLIC -# if defined(__GNUC__) || (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x590)) +# if defined(__GNUC__) # define PUBLIC __attribute__((visibility("default"))) # define USED __attribute__((used)) # elif defined(_MSC_VER) diff --git a/src/util/u_atomic_test.c b/src/util/u_atomic_test.c index 7844f616222..7a77768c966 100644 --- a/src/util/u_atomic_test.c +++ b/src/util/u_atomic_test.c @@ -26,7 +26,7 @@ **************************************************************************/ -/* Force assertions, even on debug builds. */ +/* Force assertions, even on release builds. */ #undef NDEBUG |