Mesa (master): zink: handle struct derefs in ntv
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Dec 17 19:21:51 UTC 2020
Module: Mesa
Branch: master
Commit: 02fd562e65b3007a6cc5c778c57f0f8689e65018
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=02fd562e65b3007a6cc5c778c57f0f8689e65018
Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date: Thu Jul 23 07:47:14 2020 -0400
zink: handle struct derefs in ntv
Erik Faye-Lund <erik.faye-lund at collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8142>
---
.../drivers/zink/nir_to_spirv/nir_to_spirv.c | 26 ++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
index 4c57e906a8c..e063c9495ce 100644
--- a/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
+++ b/src/gallium/drivers/zink/nir_to_spirv/nir_to_spirv.c
@@ -2177,6 +2177,28 @@ emit_deref_array(struct ntv_context *ctx, nir_deref_instr *deref)
store_dest(ctx, &deref->dest, result, nir_type_uint);
}
+static void
+emit_deref_struct(struct ntv_context *ctx, nir_deref_instr *deref)
+{
+ assert(deref->deref_type == nir_deref_type_struct);
+ nir_variable *var = nir_deref_instr_get_variable(deref);
+
+ SpvStorageClass storage_class = get_storage_class(var);
+
+ SpvId index = emit_uint_const(ctx, 32, deref->strct.index);
+
+ SpvId ptr_type = spirv_builder_type_pointer(&ctx->builder,
+ storage_class,
+ get_glsl_type(ctx, deref->type));
+
+ SpvId result = spirv_builder_emit_access_chain(&ctx->builder,
+ ptr_type,
+ get_src(ctx, &deref->parent),
+ &index, 1);
+ /* uint is a bit of a lie here, it's really just an opaque type */
+ store_dest(ctx, &deref->dest, result, nir_type_uint);
+}
+
static void
emit_deref(struct ntv_context *ctx, nir_deref_instr *deref)
{
@@ -2189,6 +2211,10 @@ emit_deref(struct ntv_context *ctx, nir_deref_instr *deref)
emit_deref_array(ctx, deref);
break;
+ case nir_deref_type_struct:
+ emit_deref_struct(ctx, deref);
+ break;
+
default:
unreachable("unexpected deref_type");
}
More information about the mesa-commit
mailing list