panfrost: Expose serialized NIR support
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 19 Oct 2019 21:14:44 +0000 (17:14 -0400)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Sat, 26 Oct 2019 13:17:42 +0000 (13:17 +0000)
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@collabora.com>
src/gallium/drivers/panfrost/pan_compute.c
src/gallium/drivers/panfrost/pan_screen.c

index 036dffbb17be12298ea04df978ec22fddb0bdf09..20a9a0904a624257fb0f2277edff0ac8706f22f2 100644 (file)
@@ -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;
 }
index d698e5071f81c3d5bec41643293ace6ef34b9ae5..8d54f8c0aa1a432806b1264a8b40056d24a68660 100644 (file)
@@ -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;