pan/bit: Open up the device
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Tue, 24 Mar 2020 17:48:06 +0000 (13:48 -0400)
committerMarge Bot <eric+marge@anholt.net>
Tue, 31 Mar 2020 01:12:26 +0000 (01:12 +0000)
As a start and a sanity check.

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

src/panfrost/bifrost/cmdline.c
src/panfrost/bifrost/test/bi_submit.c
src/panfrost/bifrost/test/bit.h
src/panfrost/meson.build

index 30120d32e3c705eebc8aa0e4985e65fe749dd8f1..f2a0848f8054fd07a0dc483a76cc6ca6c5f4f0b1 100644 (file)
@@ -30,6 +30,7 @@
 #include "compiler/nir_types.h"
 #include "util/u_dynarray.h"
 #include "bifrost_compile.h"
+#include "test/bit.h"
 
 static void
 compile_shader(char **argv)
@@ -91,6 +92,13 @@ disassemble(const char *filename)
         free(code);
 }
 
+static void
+test(void)
+{
+        void *memctx = NULL; /* TODO */
+        bit_initialize(memctx);
+}
+
 int
 main(int argc, char **argv)
 {
@@ -103,6 +111,8 @@ main(int argc, char **argv)
                 compile_shader(&argv[2]);
         else if (strcmp(argv[1], "disasm") == 0)
                 disassemble(argv[2]);
+        else if (strcmp(argv[1], "test") == 0)
+                test();
         else
                 unreachable("Unknown command. Valid: compile/disasm");
 
index fcc4459541a0ebda9013a79c1a21949aa5d1b812..b098f2aa542b93b69ac7dd93a62e2fdbb4f30178 100644 (file)
@@ -37,3 +37,20 @@ bit_bo_create(struct panfrost_device *dev, size_t size)
         pandecode_inject_mmap(bo->gpu, bo->cpu, bo->size, NULL);
         return bo;
 }
+
+struct panfrost_device *
+bit_initialize(void *memctx)
+{
+        int fd = drmOpenWithType("panfrost", NULL, DRM_NODE_RENDER);
+
+        if (fd < 0)
+                unreachable("No panfrost device found. Try chmod?");
+
+        struct panfrost_device *dev = rzalloc(memctx, struct panfrost_device);
+        panfrost_open_device(memctx, fd, dev);
+
+        pandecode_initialize(true);
+        printf("%X\n", dev->gpu_id);
+
+        return dev;
+}
index d5751f83d1fee13d8238a3822023247611f0f88e..6838da7c9eb24899e818708f53c624feb70fd8a5 100644 (file)
@@ -31,6 +31,9 @@
 #include "panfrost/encoder/pan_device.h"
 #include "panfrost/encoder/pan_bo.h"
 
+struct panfrost_device *
+bit_initialize(void *memctx);
+
 #endif
 
 
index e94a3341fb06b8b8db62bdc7d6d7c250f378e631..44b483e98e2a1f0a26423120514dd582fd7a2530 100644 (file)
@@ -62,6 +62,7 @@ bifrost_compiler = executable(
     libpanfrost_bifrost,
     libpanfrost_decode,
     libpanfrost_encoder,
+    libpanfrost_midgard, # references disassemble_midgard...
   ],
   build_by_default : true
 )