summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2015-03-27 13:48:44 -0700
committerKenneth Graunke <[email protected]>2015-03-27 21:16:43 -0700
commitac69ab7302dffa1350c64a9c69abd7721d0f0127 (patch)
treea450e79acf094b492cf0386216f34dd29b0f0740 /src
parent826d3afb8f421a62020308813397e541e672381e (diff)
i965: Move env_var_as_boolean to intel_debug.c.
I need to use this in brw_vec4.cpp, so it can't be static anymore. Signed-off-by: Kenneth Graunke <[email protected]> Reviewed-by: Matt Turner <[email protected]>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/drivers/dri/i965/brw_fs.cpp24
-rw-r--r--src/mesa/drivers/dri/i965/intel_debug.c25
-rw-r--r--src/mesa/drivers/dri/i965/intel_debug.h2
3 files changed, 29 insertions, 22 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
index 69692863bb9..9c2ccce11b2 100644
--- a/src/mesa/drivers/dri/i965/brw_fs.cpp
+++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
@@ -3850,26 +3850,6 @@ fs_visitor::allocate_registers()
prog_data->total_scratch = brw_get_scratch_size(last_scratch);
}
-static 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;
- }
-}
-
bool
fs_visitor::run_vs()
{
@@ -3881,7 +3861,7 @@ fs_visitor::run_vs()
if (INTEL_DEBUG & DEBUG_SHADER_TIME)
emit_shader_time_begin();
- if (env_var_as_boolean("INTEL_USE_NIR", false)) {
+ if (brw_env_var_as_boolean("INTEL_USE_NIR", false)) {
emit_nir_code();
} else {
foreach_in_list(ir_instruction, ir, shader->base.ir) {
@@ -3954,7 +3934,7 @@ fs_visitor::run_fs()
/* Generate FS IR for main(). (the visitor only descends into
* functions called "main").
*/
- if (env_var_as_boolean("INTEL_USE_NIR", false)) {
+ if (brw_env_var_as_boolean("INTEL_USE_NIR", false)) {
emit_nir_code();
} else if (shader) {
foreach_in_list(ir_instruction, ir, shader->base.ir) {
diff --git a/src/mesa/drivers/dri/i965/intel_debug.c b/src/mesa/drivers/dri/i965/intel_debug.c
index 0cb7aef3231..a5b883c344c 100644
--- a/src/mesa/drivers/dri/i965/intel_debug.c
+++ b/src/mesa/drivers/dri/i965/intel_debug.c
@@ -106,3 +106,28 @@ brw_process_intel_debug_variable(struct brw_context *brw)
if (INTEL_DEBUG & DEBUG_AUB)
drm_intel_bufmgr_gem_set_aub_dump(brw->bufmgr, true);
}
+
+/**
+ * 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 ed879aba8d3..807ad988a78 100644
--- a/src/mesa/drivers/dri/i965/intel_debug.h
+++ b/src/mesa/drivers/dri/i965/intel_debug.h
@@ -115,3 +115,5 @@ extern uint64_t intel_debug_flag_for_shader_stage(gl_shader_stage stage);
struct brw_context;
extern void brw_process_intel_debug_variable(struct brw_context *brw);
+
+extern bool brw_env_var_as_boolean(const char *var_name, bool default_value);