[Mesa-dev] [PATCH 11/15] glsl/standalone: Enable par-linking

Ian Romanick idr at freedesktop.org
Thu Sep 15 22:12:44 UTC 2016


From: Ian Romanick <ian.d.romanick at intel.com>

If the user did not request full linking, link the shader with the
built-in functions, inline them, and eliminate them.  Previous to this
you'd see all these calls to "dot" and "max" in the output.  This
prevented a lot of expected optimizations and cluttered the output.
This gives it some chance of being useful.

Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
 src/compiler/glsl/standalone.cpp | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index f7e1055..1b2a575 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -38,6 +38,8 @@
 #include "standalone.h"
 #include "util/string_to_uint_map.h"
 #include "util/set.h"
+#include "linker.h"
+#include "glsl_parser_extras.h"
 
 class add_neg_to_sub_visitor : public ir_hierarchical_visitor {
 public:
@@ -506,10 +508,34 @@ standalone_compile_shader(const struct standalone_options *_options,
       }
    }
 
-   if ((status == EXIT_SUCCESS) && options->do_link)  {
+   if (status == EXIT_SUCCESS) {
       _mesa_clear_shader_program_data(whole_program);
 
-      link_shaders(ctx, whole_program);
+      if (options->do_link)  {
+         link_shaders(ctx, whole_program);
+      } else {
+         struct gl_shader *const shader = whole_program->Shaders[0];
+
+         whole_program->LinkStatus = GL_TRUE;
+         whole_program->_LinkedShaders[shader->Stage] =
+            link_intrastage_shaders(whole_program /* mem_ctx */,
+                                    ctx,
+                                    whole_program,
+                                    whole_program->Shaders,
+                                    1,
+                                    true);
+
+         struct gl_shader_compiler_options *const compiler_options =
+            &ctx->Const.ShaderCompilerOptions[shader->Stage];
+
+         do_common_optimization(whole_program->_LinkedShaders[shader->Stage]->ir,
+                                false,
+                                false,
+                                compiler_options,
+                                true,
+                                true);
+      }
+
       status = (whole_program->LinkStatus) ? EXIT_SUCCESS : EXIT_FAILURE;
 
       if (strlen(whole_program->InfoLog) > 0) {
-- 
2.5.5



More information about the mesa-dev mailing list