[Mesa-dev] [PATCH 08/10] glsl: use NIR function inlining for drivers that use glsl_to_nir

Timothy Arceri tarceri at itsqueeze.com
Mon May 21 02:27:49 UTC 2018


On 21/05/18 10:38, Dieter Nützel wrote:
> Hello Tim,
> 
> progress on this one?

I believe Matt was working on a series that uses these changes as a 
base. The series was never fully reviewed and it didn't help as much 
with radeonsi compile times as I'd hoped so I'll let Matt push/review 
this if he is interested.

Patch 5 is a bug fix so we should probably at least land that.

Tim

> 
> Happy Pentecost!
> 
> Dieter
> 
> Am 10.04.2018 06:34, schrieb Timothy Arceri:
>> ---
>>  src/compiler/glsl/glsl_to_nir.cpp | 20 ++++++++++++++++++++
>>  1 file changed, 20 insertions(+)
>>
>> diff --git a/src/compiler/glsl/glsl_to_nir.cpp
>> b/src/compiler/glsl/glsl_to_nir.cpp
>> index 5a36963607e..55c01024669 100644
>> --- a/src/compiler/glsl/glsl_to_nir.cpp
>> +++ b/src/compiler/glsl/glsl_to_nir.cpp
>> @@ -26,6 +26,7 @@
>>   */
>>
>>  #include "glsl_to_nir.h"
>> +#include "ir_optimization.h"
>>  #include "ir_visitor.h"
>>  #include "ir_hierarchical_visitor.h"
>>  #include "ir.h"
>> @@ -161,6 +162,25 @@ glsl_to_nir(const struct gl_shader_program 
>> *shader_prog,
>>     v2.run(sh->ir);
>>     visit_exec_list(sh->ir, &v1);
>>
>> +   nir_validate_shader(shader);
>> +
>> +   /* We have to lower away local constant initializers right before we
>> +    * inline functions.  That way they get properly initialized at 
>> the top
>> +    * of the function and not at the top of its caller.
>> +    */
>> +   nir_lower_constant_initializers(shader, nir_var_local);
>> +   nir_lower_returns(shader);
>> +   nir_inline_functions(shader);
>> +
>> +   /* Now that we have inlined everything remove all of the functions 
>> except
>> +    * main().
>> +    */
>> +   foreach_list_typed_safe(nir_function, function, node, 
>> &(shader)->functions){
>> +      if (strcmp("main", function->name) != 0) {
>> +         exec_node_remove(&function->node);
>> +      }
>> +   }
>> +
>>     nir_lower_constant_initializers(shader, (nir_variable_mode)~0);
>>
>>     /* Remap the locations to slots so those requiring two slots will 
>> occupy


More information about the mesa-dev mailing list