From 48ea3bbff6ad1ce9f028097660da6c2d30338fe5 Mon Sep 17 00:00:00 2001 From: Caio Marcelo de Oliveira Filho Date: Thu, 9 May 2019 19:33:51 -0700 Subject: [PATCH] spirv: Add vtn_variable_mode_image Corresponding to SpvStorageClassImage. We see pointers for that storage class in tests, but don't use the storage class any further. Adding this so that we can call vtn_mode_to_address_format() for all supported pointers. v2: Fail when trying to create a SpvStorageClassImage variable. (Jason) Reviewed-by: Jason Ekstrand Reviewed-by: Bas Nieuwenhuizen --- src/compiler/spirv/vtn_private.h | 1 + src/compiler/spirv/vtn_variables.c | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/compiler/spirv/vtn_private.h b/src/compiler/spirv/vtn_private.h index a66f2c02fbd..c0595709852 100644 --- a/src/compiler/spirv/vtn_private.h +++ b/src/compiler/spirv/vtn_private.h @@ -438,6 +438,7 @@ enum vtn_variable_mode { vtn_variable_mode_cross_workgroup, vtn_variable_mode_input, vtn_variable_mode_output, + vtn_variable_mode_image, }; struct vtn_pointer { diff --git a/src/compiler/spirv/vtn_variables.c b/src/compiler/spirv/vtn_variables.c index 11d3111c516..198557f2eaf 100644 --- a/src/compiler/spirv/vtn_variables.c +++ b/src/compiler/spirv/vtn_variables.c @@ -1779,6 +1779,10 @@ vtn_storage_class_to_mode(struct vtn_builder *b, mode = vtn_variable_mode_cross_workgroup; nir_mode = nir_var_mem_global; break; + case SpvStorageClassImage: + mode = vtn_variable_mode_image; + nir_mode = nir_var_mem_ubo; + break; case SpvStorageClassGeneric: default: vtn_fail("Unhandled variable storage class: %s (%u)", @@ -1822,6 +1826,7 @@ vtn_mode_to_address_format(struct vtn_builder *b, enum vtn_variable_mode mode) case vtn_variable_mode_uniform: case vtn_variable_mode_input: case vtn_variable_mode_output: + case vtn_variable_mode_image: return nir_address_format_logical; } @@ -2082,6 +2087,10 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, b->shader->num_uniforms = vtn_type_block_size(b, type); break; + case vtn_variable_mode_image: + vtn_fail("Cannot create a variable with the Image storage class"); + break; + case vtn_variable_mode_phys_ssbo: vtn_fail("Cannot create a variable with the " "PhysicalStorageBufferEXT storage class"); @@ -2244,6 +2253,7 @@ vtn_create_variable(struct vtn_builder *b, struct vtn_value *val, /* These don't need actual variables. */ break; + case vtn_variable_mode_image: case vtn_variable_mode_phys_ssbo: unreachable("Should have been caught before"); } -- 2.30.2