From: Kenneth Graunke Date: Fri, 27 Mar 2015 20:48:44 +0000 (-0700) Subject: i965: Move env_var_as_boolean to intel_debug.c. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=ac69ab7302dffa1350c64a9c69abd7721d0f0127;p=mesa.git 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 Reviewed-by: Matt Turner --- 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);