mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-02-08 14:20:30 +01:00
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 <robclark@freedesktop.org> Reviewed-by: Nicolai Hähnle <nhaehnle@gmail.com>
This commit is contained in:
parent
d3e2c48dfa
commit
d278e31459
7 changed files with 35 additions and 31 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 */
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue