Mesa (master): panfrost: Expose serialized NIR support

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Oct 26 13:41:54 UTC 2019


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

Author: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>
Date:   Sat Oct 19 17:14:44 2019 -0400

panfrost: Expose serialized NIR support

Serialized NIR is required for clover with the SPIR-V pipeline. With
this change and PAN_MESA_DEBUG=deqp, clinfo is able to successfully
probe panfrost.

Code from Nouveau (commit 7955fabcf89c7265f7f4244e46c5bcb83b9687fa by
Karol Herbst).

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig at collabora.com>

---

 src/gallium/drivers/panfrost/pan_compute.c | 15 ++++++++++++---
 src/gallium/drivers/panfrost/pan_screen.c  |  2 +-
 2 files changed, 13 insertions(+), 4 deletions(-)

diff --git a/src/gallium/drivers/panfrost/pan_compute.c b/src/gallium/drivers/panfrost/pan_compute.c
index 036dffbb17b..20a9a0904a6 100644
--- a/src/gallium/drivers/panfrost/pan_compute.c
+++ b/src/gallium/drivers/panfrost/pan_compute.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (C) 2019 Collabora, Ltd.
+ * Copyright (C) 2019 Red Hat Inc.
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -27,6 +28,7 @@
 
 #include "pan_context.h"
 #include "util/u_memory.h"
+#include "nir_serialize.h"
 
 /* Compute CSOs are tracked like graphics shader CSOs, but are
  * considerably simpler. We do not implement multiple
@@ -51,11 +53,18 @@ panfrost_create_compute_state(
 
         v->tripipe = malloc(sizeof(struct mali_shader_meta));
 
-        panfrost_shader_compile(ctx, v->tripipe,
-                        cso->ir_type, cso->prog,
-                        MESA_SHADER_COMPUTE, v, NULL);
+        if (cso->ir_type == PIPE_SHADER_IR_NIR_SERIALIZED) {
+                struct blob_reader reader;
+                const struct pipe_binary_program_header *hdr = cso->prog;
 
+                blob_reader_init(&reader, hdr->blob, hdr->num_bytes);
+                so->cbase.prog = nir_deserialize(NULL, &midgard_nir_options, &reader);
+                so->cbase.ir_type = PIPE_SHADER_IR_NIR;
+        }
 
+        panfrost_shader_compile(ctx, v->tripipe,
+                        so->cbase.ir_type, so->cbase.prog,
+                        MESA_SHADER_COMPUTE, v, NULL);
 
         return so;
 }
diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c
index d698e5071f8..8d54f8c0aa1 100644
--- a/src/gallium/drivers/panfrost/pan_screen.c
+++ b/src/gallium/drivers/panfrost/pan_screen.c
@@ -330,7 +330,7 @@ panfrost_get_shader_param(struct pipe_screen *screen,
                 return PIPE_SHADER_IR_NIR;
 
         case PIPE_SHADER_CAP_SUPPORTED_IRS:
-                return (1 << PIPE_SHADER_IR_NIR);
+                return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_NIR_SERIALIZED);
 
         case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
                 return 32;




More information about the mesa-commit mailing list