summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark <[email protected]>2015-11-18 16:43:31 -0500
committerRob Clark <[email protected]>2015-11-24 10:02:55 -0500
commitd278e31459374feb18edd97d5adaacccc08f978a (patch)
tree39a401065cc3701c7abcd8ae0eeedf7cdd6d8ebd
parentd3e2c48dfa669899484159cf723d8da574996f65 (diff)
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 <[email protected]> Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.c5
-rw-r--r--src/mesa/drivers/dri/i965/brw_nir.c4
-rw-r--r--src/mesa/drivers/dri/i965/brw_shader.cpp3
-rw-r--r--src/mesa/drivers/dri/i965/intel_debug.c25
-rw-r--r--src/mesa/drivers/dri/i965/intel_debug.h2
-rw-r--r--src/util/debug.c25
-rw-r--r--src/util/debug.h2
7 files changed, 35 insertions, 31 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
index 2ea0a9eca92..7e2fdcbe60c 100644
--- a/src/mesa/drivers/dri/i965/brw_context.c
+++ b/src/mesa/drivers/dri/i965/brw_context.c
@@ -69,6 +69,7 @@
#include "tnl/tnl.h"
#include "tnl/t_pipeline.h"
#include "util/ralloc.h"
+#include "util/debug.h"
/***************************************
* Mesa's Driver Functions
@@ -899,8 +900,8 @@ brwCreateContext(gl_api api,
brw->predicate.state = BRW_PREDICATE_STATE_RENDER;
brw->use_resource_streamer = screen->has_resource_streamer &&
- (brw_env_var_as_boolean("INTEL_USE_HW_BT", false) ||
- brw_env_var_as_boolean("INTEL_USE_GATHER", false));
+ (env_var_as_boolean("INTEL_USE_HW_BT", false) ||
+ env_var_as_boolean("INTEL_USE_GATHER", false));
ctx->VertexProgram._MaintainTnlProgram = true;
ctx->FragmentProgram._MaintainTexEnvProgram = true;
diff --git a/src/mesa/drivers/dri/i965/brw_nir.c b/src/mesa/drivers/dri/i965/brw_nir.c
index 91358d8f389..5d9a2fedcce 100644
--- a/src/mesa/drivers/dri/i965/brw_nir.c
+++ b/src/mesa/drivers/dri/i965/brw_nir.c
@@ -171,12 +171,14 @@ brw_nir_lower_outputs(nir_shader *nir, bool is_scalar)
}
}
+#include "util/debug.h"
+
static bool
should_clone_nir()
{
static int should_clone = -1;
if (should_clone < 1)
- should_clone = brw_env_var_as_boolean("NIR_TEST_CLONE", false);
+ should_clone = env_var_as_boolean("NIR_TEST_CLONE", false);
return should_clone;
}
diff --git a/src/mesa/drivers/dri/i965/brw_shader.cpp b/src/mesa/drivers/dri/i965/brw_shader.cpp
index 7a236cd9880..cf0136ac86b 100644
--- a/src/mesa/drivers/dri/i965/brw_shader.cpp
+++ b/src/mesa/drivers/dri/i965/brw_shader.cpp
@@ -31,6 +31,7 @@
#include "glsl/ir_optimization.h"
#include "glsl/glsl_parser_extras.h"
#include "main/shaderapi.h"
+#include "util/debug.h"
static void
shader_debug_log_mesa(void *data, const char *fmt, ...)
@@ -87,7 +88,7 @@ brw_compiler_create(void *mem_ctx, const struct brw_device_info *devinfo)
compiler->scalar_stage[MESA_SHADER_VERTEX] =
devinfo->gen >= 8 && !(INTEL_DEBUG & DEBUG_VEC4VS);
compiler->scalar_stage[MESA_SHADER_GEOMETRY] =
- devinfo->gen >= 8 && brw_env_var_as_boolean("INTEL_SCALAR_GS", false);
+ devinfo->gen >= 8 && env_var_as_boolean("INTEL_SCALAR_GS", false);
compiler->scalar_stage[MESA_SHADER_FRAGMENT] = true;
compiler->scalar_stage[MESA_SHADER_COMPUTE] = true;
diff --git a/src/mesa/drivers/dri/i965/intel_debug.c b/src/mesa/drivers/dri/i965/intel_debug.c
index f53c4ab518a..7d8b966185c 100644
--- a/src/mesa/drivers/dri/i965/intel_debug.c
+++ b/src/mesa/drivers/dri/i965/intel_debug.c
@@ -103,28 +103,3 @@ brw_process_intel_debug_variable(void)
uint64_t intel_debug = parse_debug_string(getenv("INTEL_DEBUG"), debug_control);
(void) p_atomic_cmpxchg(&INTEL_DEBUG, 0, intel_debug);
}
-
-/**
- * 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
-brw_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/mesa/drivers/dri/i965/intel_debug.h b/src/mesa/drivers/dri/i965/intel_debug.h
index 9c6030a6d7d..175ac68a7c8 100644
--- a/src/mesa/drivers/dri/i965/intel_debug.h
+++ b/src/mesa/drivers/dri/i965/intel_debug.h
@@ -120,5 +120,3 @@ extern uint64_t INTEL_DEBUG;
extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
extern void brw_process_intel_debug_variable(void);
-
-extern bool brw_env_var_as_boolean(const char *var_name, bool default_value);
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..35554179ab0 100644
--- a/src/util/debug.h
+++ b/src/util/debug.h
@@ -38,6 +38,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 */