[Mesa-dev] [PATCH 2/9] i965/nir: Make our environment variable checking smarter

Jason Ekstrand jason at jlekstrand.net
Wed Mar 18 15:23:18 PDT 2015


On Wed, Mar 18, 2015 at 3:17 PM, Mark Janes <mark.a.janes at intel.com> wrote:
> Reviewed-by: Mark Janes <mark.a.janes at intel.com>

Thanks!  Noted.

>
> Jason Ekstrand <jason at jlekstrand.net> writes:
>
>> Before, we enabled NIR if you set INTEL_USE_NIR to anything which mean that
>> INTEL_USE_NIR=false would actually turn on NIR.  In preparation for turning
>> NIR on by default, this commit makes it smarter by allowing the
>> INTEL_USE_NIR variable to work as either a force-enable or a force-disable.
>> ---
>>  src/mesa/drivers/dri/i965/brw_fs.cpp | 24 ++++++++++++++++++++++--
>>  1 file changed, 22 insertions(+), 2 deletions(-)
>>
>> diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> index 53ceb29..3d4d31a 100644
>> --- a/src/mesa/drivers/dri/i965/brw_fs.cpp
>> +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp
>> @@ -3838,6 +3838,26 @@ 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()
>>  {
>> @@ -3849,7 +3869,7 @@ fs_visitor::run_vs()
>>     if (INTEL_DEBUG & DEBUG_SHADER_TIME)
>>        emit_shader_time_begin();
>>
>> -   if (getenv("INTEL_USE_NIR") != NULL) {
>> +   if (env_var_as_boolean("INTEL_USE_NIR", false)) {
>>        emit_nir_code();
>>     } else {
>>        foreach_in_list(ir_instruction, ir, shader->base.ir) {
>> @@ -3923,7 +3943,7 @@ fs_visitor::run_fs()
>>         * functions called "main").
>>         */
>>        if (shader) {
>> -         if (getenv("INTEL_USE_NIR") != NULL) {
>> +         if (env_var_as_boolean("INTEL_USE_NIR", false)) {
>>              emit_nir_code();
>>           } else {
>>              foreach_in_list(ir_instruction, ir, shader->base.ir) {
>> --
>> 2.3.2
>>
>> _______________________________________________
>> mesa-dev mailing list
>> mesa-dev at lists.freedesktop.org
>> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list