mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-09 02:28:10 +02:00
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 <kenneth@whitecape.org> Reviewed-by: Matt Turner <mattst88@gmail.com>
This commit is contained in:
parent
826d3afb8f
commit
ac69ab7302
3 changed files with 29 additions and 22 deletions
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue