Mesa (master): zink: add get_storage_class() ntv util

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Dec 17 19:21:51 UTC 2020


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

Author: Mike Blumenkrantz <michael.blumenkrantz at gmail.com>
Date:   Thu Dec 17 12:31:46 2020 -0500

zink: add get_storage_class() ntv util

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       | 28 ++++++++++++----------
 1 file changed, 15 insertions(+), 13 deletions(-)

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 ff383e081c6..4c57e906a8c 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
@@ -179,6 +179,20 @@ get_uvec_type(struct ntv_context *ctx, unsigned bit_size, unsigned num_component
    return uint_type;
 }
 
+static SpvStorageClass
+get_storage_class(struct nir_variable *var)
+{
+   switch (var->data.mode) {
+   case nir_var_shader_in:
+      return SpvStorageClassInput;
+   case nir_var_shader_out:
+      return SpvStorageClassOutput;
+   default:
+      unreachable("Unsupported nir_variable_mode");
+   }
+   return 0;
+}
+
 static SpvId
 get_dest_uvec_type(struct ntv_context *ctx, nir_dest *dest)
 {
@@ -2147,19 +2161,7 @@ emit_deref_array(struct ntv_context *ctx, nir_deref_instr *deref)
    assert(deref->deref_type == nir_deref_type_array);
    nir_variable *var = nir_deref_instr_get_variable(deref);
 
-   SpvStorageClass storage_class;
-   switch (var->data.mode) {
-   case nir_var_shader_in:
-      storage_class = SpvStorageClassInput;
-      break;
-
-   case nir_var_shader_out:
-      storage_class = SpvStorageClassOutput;
-      break;
-
-   default:
-      unreachable("Unsupported nir_variable_mode\n");
-   }
+   SpvStorageClass storage_class = get_storage_class(var);
 
    SpvId index = get_src(ctx, &deref->arr.index);
 



More information about the mesa-commit mailing list