Mesa (master): pan/bit: Add `run` mode to the cmdline

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 1 02:42:47 UTC 2020


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Mon Mar 30 21:21:49 2020 -0400

pan/bit: Add `run` mode to the cmdline

This emulates the functionality of shader_runner (built for kbase) using
the bifrost testing infrastructure so it runs on mainline. Ideally this
will let us test shaders from the assembler.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4396>

---

 src/panfrost/bifrost/cmdline.c | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)

diff --git a/src/panfrost/bifrost/cmdline.c b/src/panfrost/bifrost/cmdline.c
index 24dd3c2d5a5..a62f230cbba 100644
--- a/src/panfrost/bifrost/cmdline.c
+++ b/src/panfrost/bifrost/cmdline.c
@@ -106,6 +106,38 @@ test_vertex(char **argv)
         bit_vertex(dev, compile_shader(argv, true));
 }
 
+static void
+run(const char *filename)
+{
+        FILE *fp = fopen(filename, "rb");
+        assert(fp);
+
+        fseek(fp, 0, SEEK_END);
+        unsigned filesize = ftell(fp);
+        rewind(fp);
+
+        unsigned char *code = malloc(filesize);
+        unsigned res = fread(code, 1, filesize, fp);
+        if (res != filesize) {
+                printf("Couldn't read full file\n");
+        }
+        fclose(fp);
+
+        void *memctx = NULL; /* TODO */
+        struct panfrost_device *dev = bit_initialize(memctx);
+
+        panfrost_program prog = {
+                .compiled = {
+                        .data = code,
+                        .size = filesize
+                },
+        };
+
+        bit_vertex(dev, prog);
+
+        free(code);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -120,6 +152,8 @@ main(int argc, char **argv)
                 disassemble(argv[2]);
         else if (strcmp(argv[1], "test-vertex") == 0)
                 test_vertex(&argv[2]);
+        else if (strcmp(argv[1], "run") == 0)
+                run(argv[2]);
         else
                 unreachable("Unknown command. Valid: compile/disasm");
 



More information about the mesa-commit mailing list