[Mesa-dev] [PATCH 09/17] nir: Fix wonkey indentation in generated code

Ian Romanick idr at freedesktop.org
Thu Aug 27 04:55:59 PDT 2015


On 08/26/2015 06:44 PM, Jason Ekstrand wrote:
> I think I'd rather just run it through indent like we do for some of
> the other auto-generated code.  That way the mako file (the one you'll
> actually be editing) can remain readable.

I had thought about doing that.  We use indent in a few places where
it's hard (sometimes really, really hard for some GLX protocol code) to
have the generator do proper formatting.  In places where it's easy to
have the generator do proper formatting, we've preferred to not run
extra programs as part of the build.

> --Jason
> 
> On Wed, Aug 26, 2015 at 10:19 AM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>  src/glsl/nir/nir_constant_expressions.py | 40 ++++++++++++++++----------------
>>  1 file changed, 20 insertions(+), 20 deletions(-)
>>
>> diff --git a/src/glsl/nir/nir_constant_expressions.py b/src/glsl/nir/nir_constant_expressions.py
>> index 6006358..087aab9 100644
>> --- a/src/glsl/nir/nir_constant_expressions.py
>> +++ b/src/glsl/nir/nir_constant_expressions.py
>> @@ -238,29 +238,29 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
>>           <% continue %>
>>        %endif
>>
>> -      struct ${op.input_types[j]}_vec src${j} = {
>> +   struct ${op.input_types[j]}_vec src${j} = {
>>        % for k in range(op.input_sizes[j]):
>>           % if op.input_types[j] == "bool":
>> -            _src[${j}].u[${k}] != 0,
>> +      _src[${j}].u[${k}] != 0,
>>           % else:
>> -            _src[${j}].${op.input_types[j][:1]}[${k}],
>> +      _src[${j}].${op.input_types[j][:1]}[${k}],
>>           % endif
>>        % endfor
>>        % for k in range(op.input_sizes[j], 4):
>>           % if op.input_types[j] == "bool":
>> -            false,
>> +      false,
>>           % else:
>> -            0,
>> +      0,
>>           % endif
>>        % endfor
>> -      };
>> +   };
>>     % endfor
>>
>>     % if op.output_size == 0:
>>        ## For per-component instructions, we need to iterate over the
>>        ## components and apply the constant expression one component
>>        ## at a time.
>> -      for (unsigned _i = 0; _i < num_components; _i++) {
>> +   for (unsigned _i = 0; _i < num_components; _i++) {
>>           ## For each per-component input, create a variable srcN that
>>           ## contains the value of the current (_i'th) component.
>>           % for j in range(op.num_inputs):
>> @@ -270,9 +270,9 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
>>                 ## Avoid unused variable warnings
>>                 <% continue %>
>>              % elif op.input_types[j] == "bool":
>> -               bool src${j} = _src[${j}].u[_i] != 0;
>> +      bool src${j} = _src[${j}].u[_i] != 0;
>>              % else:
>> -               ${op.input_types[j]} src${j} = _src[${j}].${op.input_types[j][:1]}[_i];
>> +      ${op.input_types[j]} src${j} = _src[${j}].${op.input_types[j][:1]}[_i];
>>              % endif
>>           % endfor
>>
>> @@ -280,36 +280,36 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
>>           ## result of the const_expr to it.  If const_expr already contains
>>           ## writes to dst, just include const_expr directly.
>>           % if "dst" in op.const_expr:
>> -            ${op.output_type} dst;
>> -            ${op.const_expr}
>> +      ${op.output_type} dst;
>> +      ${op.const_expr}
>>           % else:
>> -            ${op.output_type} dst = ${op.const_expr};
>> +      ${op.output_type} dst = ${op.const_expr};
>>           % endif
>>
>>           ## Store the current component of the actual destination to the
>>           ## value of dst.
>>           % if op.output_type == "bool":
>>              ## Sanitize the C value to a proper NIR bool
>> -            _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
>> +      _dst_val.u[_i] = dst ? NIR_TRUE : NIR_FALSE;
>>           % else:
>> -            _dst_val.${op.output_type[:1]}[_i] = dst;
>> +      _dst_val.${op.output_type[:1]}[_i] = dst;
>>           % endif
>> -      }
>> +   }
>>     % else:
>>        ## In the non-per-component case, create a struct dst with
>>        ## appropriately-typed elements x, y, z, and w and assign the result
>>        ## of the const_expr to all components of dst, or include the
>>        ## const_expr directly if it writes to dst already.
>> -      struct ${op.output_type}_vec dst;
>> +   struct ${op.output_type}_vec dst;
>>
>>        % if "dst" in op.const_expr:
>> -         ${op.const_expr}
>> +   ${op.const_expr}
>>        % else:
>>           ## Splat the value to all components.  This way expressions which
>>           ## write the same value to all components don't need to explicitly
>>           ## write to dest.  One such example is fnoise which has a
>>           ## const_expr of 0.0f.
>> -         dst.x = dst.y = dst.z = dst.w = ${op.const_expr};
>> +   dst.x = dst.y = dst.z = dst.w = ${op.const_expr};
>>        % endif
>>
>>        ## For each component in the destination, copy the value of dst to
>> @@ -317,9 +317,9 @@ evaluate_${name}(unsigned num_components, nir_const_value *_src)
>>        % for k in range(op.output_size):
>>           % if op.output_type == "bool":
>>              ## Sanitize the C value to a proper NIR bool
>> -            _dst_val.u[${k}] = dst.${"xyzw"[k]} ? NIR_TRUE : NIR_FALSE;
>> +   _dst_val.u[${k}] = dst.${"xyzw"[k]} ? NIR_TRUE : NIR_FALSE;
>>           % else:
>> -            _dst_val.${op.output_type[:1]}[${k}] = dst.${"xyzw"[k]};
>> +   _dst_val.${op.output_type[:1]}[${k}] = dst.${"xyzw"[k]};
>>           % endif
>>        % endfor
>>     % endif
>> --
>> 2.1.0
>>
>> _______________________________________________
>> 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