[Mesa-dev] [PATCH 08/10] glsl: use NIR function inlining for drivers that use glsl_to_nir
Timothy Arceri
tarceri at itsqueeze.com
Tue Apr 10 04:34:33 UTC 2018
---
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
--
2.17.0
More information about the mesa-dev
mailing list