From d4748913fc4923649c0982bd32a0a34a68e1fe0f Mon Sep 17 00:00:00 2001 From: Mike Blumenkrantz Date: Thu, 17 Dec 2020 12:31:46 -0500 Subject: [PATCH] zink: add get_storage_class() ntv util Erik Faye-Lund Part-of: --- .../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);