spirv: Add vtn_variable_mode_image
authorCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Fri, 10 May 2019 02:33:51 +0000 (19:33 -0700)
committerCaio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
Mon, 20 May 2019 17:53:38 +0000 (10:53 -0700)
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 <jason@jlekstrand.net>
Reviewed-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl>
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index a66f2c02fbdf60124ccf83d8ad3a6f4a0527d788..c0595709852156df03cc160dd49e3cec7dde8393 100644 (file)
@@ -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 {
index 11d3111c516bf352b2795e5df43c706c34efb131..198557f2eaf21d2ad7f105fec31bfd8cf927c4d2 100644 (file)
@@ -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");
    }