Mesa (main): freedreno: Add PIPE_SHADER_IR_NIR_SERIALIZED support
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Mon Nov 15 18:27:17 UTC 2021
Module: Mesa
Branch: main
Commit: 9e7f5b75ecf4c4da336d82c426508c925932013f
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=9e7f5b75ecf4c4da336d82c426508c925932013f
Author: Rob Clark <robdclark at chromium.org>
Date: Sun Aug 8 10:55:03 2021 -0700
freedreno: Add PIPE_SHADER_IR_NIR_SERIALIZED support
Signed-off-by: Rob Clark <robdclark at chromium.org>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12500>
---
src/gallium/drivers/freedreno/freedreno_screen.c | 5 ++++-
src/gallium/drivers/freedreno/ir3/ir3_gallium.c | 11 +++++++++++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_screen.c b/src/gallium/drivers/freedreno/freedreno_screen.c
index 495b456698b..3402366541d 100644
--- a/src/gallium/drivers/freedreno/freedreno_screen.c
+++ b/src/gallium/drivers/freedreno/freedreno_screen.c
@@ -666,7 +666,10 @@ fd_screen_get_shader_param(struct pipe_screen *pscreen,
case PIPE_SHADER_CAP_PREFERRED_IR:
return PIPE_SHADER_IR_NIR;
case PIPE_SHADER_CAP_SUPPORTED_IRS:
- return (1 << PIPE_SHADER_IR_NIR) | (1 << PIPE_SHADER_IR_TGSI);
+ return (1 << PIPE_SHADER_IR_NIR) |
+ COND(has_compute(screen) && (shader == PIPE_SHADER_COMPUTE),
+ (1 << PIPE_SHADER_IR_NIR_SERIALIZED)) |
+ (1 << PIPE_SHADER_IR_TGSI);
case PIPE_SHADER_CAP_MAX_UNROLL_ITERATIONS_HINT:
return 32;
case PIPE_SHADER_CAP_MAX_SHADER_BUFFERS:
diff --git a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
index f26e8103421..06ea8fec32c 100644
--- a/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
+++ b/src/gallium/drivers/freedreno/ir3/ir3_gallium.c
@@ -34,6 +34,7 @@
#include "util/u_string.h"
#include "nir/tgsi_to_nir.h"
+#include "nir_serialize.h"
#include "freedreno_context.h"
#include "freedreno_util.h"
@@ -288,6 +289,16 @@ ir3_shader_compute_state_create(struct pipe_context *pctx,
if (cso->ir_type == PIPE_SHADER_IR_NIR) {
/* we take ownership of the reference: */
nir = (nir_shader *)cso->prog;
+ } else if (cso->ir_type == PIPE_SHADER_IR_NIR_SERIALIZED) {
+ const nir_shader_compiler_options *options =
+ ir3_get_compiler_options(compiler);
+ const struct pipe_binary_program_header *hdr = cso->prog;
+ struct blob_reader reader;
+
+ blob_reader_init(&reader, hdr->blob, hdr->num_bytes);
+ nir = nir_deserialize(NULL, options, &reader);
+
+ ir3_finalize_nir(compiler, nir);
} else {
debug_assert(cso->ir_type == PIPE_SHADER_IR_TGSI);
if (ir3_shader_debug & IR3_DBG_DISASM) {
More information about the mesa-commit
mailing list