Module: Mesa
Branch: master
Commit: fca491c0e100ac89295dfa36ddcb63d6cb839bed
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=fca491c0e100ac89295dfa36ddcb63d6cb839bed

Author: Alyssa Rosenzweig <alyssa.rosenzw...@collabora.com>
Date:   Wed Aug 14 12:21:23 2019 -0700

pan/bifrost: Stub out standalone compiler

We don't actually have a standalone compiler in-tree yet, but let's get
prepared for when we do.

Signed-off-by: Ryan Houdek <sonicadvan...@gmail.com>
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzw...@collabora.com>

---

 src/panfrost/bifrost/cmdline.c | 49 ++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 47 insertions(+), 2 deletions(-)

diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c
index 9fd7094ebe1..4a30d7ec9f6 100644
--- a/src/panfrost/bifrost/cmdline.c
+++ b/src/panfrost/bifrost/cmdline.c
@@ -21,14 +21,56 @@
  * SOFTWARE.
  */
 
+#include "disassemble.h"
+
 #include "main/mtypes.h"
 #include "compiler/glsl/standalone.h"
 #include "compiler/glsl/glsl_to_nir.h"
+#include "compiler/glsl/gl_nir.h"
 #include "compiler/nir_types.h"
-#include "disassemble.h"
 #include "util/u_dynarray.h"
 
 static void
+compile_shader(char **argv)
+{
+        struct gl_shader_program *prog;
+        nir_shader *nir[2];
+        unsigned shader_types[2] = {
+                MESA_SHADER_VERTEX,
+                MESA_SHADER_FRAGMENT,
+        };
+
+        struct standalone_options options = {
+                .glsl_version = 430,
+                .do_link = true,
+        };
+
+        static struct gl_context local_ctx;
+
+        prog = standalone_compile_shader(&options, 2, argv, &local_ctx);
+        prog->_LinkedShaders[MESA_SHADER_FRAGMENT]->Program->info.stage = 
MESA_SHADER_FRAGMENT;
+
+#if 0
+        struct bifrost_program compiled;
+        for (unsigned i = 0; i < 2; ++i) {
+                nir[i] = glsl_to_nir(&local_ctx, prog, shader_types[i], 
&bifrost_nir_options);
+                NIR_PASS_V(nir[i], nir_lower_global_vars_to_local);
+                NIR_PASS_V(nir[i], nir_split_var_copies);
+                NIR_PASS_V(nir[i], nir_lower_var_copies);
+
+                NIR_PASS_V(nir[i], nir_lower_alu_to_scalar, NULL);
+
+                /* before buffers and vars_to_ssa */
+                NIR_PASS_V(nir[i], gl_nir_lower_bindless_images);
+
+                NIR_PASS_V(nir[i], gl_nir_lower_buffers, prog);
+                NIR_PASS_V(nir[i], nir_opt_constant_folding);
+                bifrost_compile_shader_nir(nir[i], &compiled);
+        }
+#endif
+}
+
+static void
 disassemble(const char *filename)
 {
         FILE *fp = fopen(filename, "rb");
@@ -56,7 +98,10 @@ main(int argc, char **argv)
                 printf("Pass a command\n");
                 exit(1);
         }
-        if (strcmp(argv[1], "disasm") == 0) {
+        if (strcmp(argv[1], "compile") == 0) {
+                compile_shader(&argv[2]);
+        }
+        else if (strcmp(argv[1], "disasm") == 0) {
                 disassemble(argv[2]);
         }
         return 0;

_______________________________________________
mesa-commit mailing list
mesa-commit@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to