spirv: Remove the type from sampled_image
authorJason Ekstrand <jason@jlekstrand.net>
Thu, 26 Sep 2019 16:48:44 +0000 (11:48 -0500)
committerJason Ekstrand <jason@jlekstrand.net>
Sat, 9 Nov 2019 15:29:01 +0000 (15:29 +0000)
We have types on all vtn_values at this point so there's no reason to
carry the redundant type information.

Reviewed-by: Caio Marcelo de Oliveira Filho <caio.oliveira@intel.com>
src/compiler/spirv/spirv_to_nir.c
src/compiler/spirv/vtn_cfg.c
src/compiler/spirv/vtn_private.h
src/compiler/spirv/vtn_variables.c

index eeca640ba497dfde2c69af770057c5b61cbb0baa..013805b842a8a90aa08bc82ea0d5c79126e81b8d 100644 (file)
@@ -2246,8 +2246,6 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       struct vtn_value *val =
          vtn_push_value(b, w[2], vtn_value_type_sampled_image);
       val->sampled_image = ralloc(b, struct vtn_sampled_image);
-      val->sampled_image->type =
-         vtn_value(b, w[1], vtn_value_type_type)->type;
       val->sampled_image->image =
          vtn_value(b, w[3], vtn_value_type_pointer)->pointer;
       val->sampled_image->sampler =
@@ -2272,12 +2270,11 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       sampled = *sampled_val->sampled_image;
    } else {
       vtn_assert(sampled_val->value_type == vtn_value_type_pointer);
-      sampled.type = sampled_val->pointer->type;
       sampled.image = NULL;
       sampled.sampler = sampled_val->pointer;
    }
 
-   const struct glsl_type *image_type = sampled.type->type;
+   const struct glsl_type *image_type = sampled_val->type->type;
    const enum glsl_sampler_dim sampler_dim = glsl_get_sampler_dim(image_type);
    const bool is_array = glsl_sampler_type_is_array(image_type);
    nir_alu_type dest_type = nir_type_invalid;
@@ -2300,7 +2297,7 @@ vtn_handle_texture(struct vtn_builder *b, SpvOp opcode,
       break;
 
    case SpvOpImageFetch:
-      if (glsl_get_sampler_dim(image_type) == GLSL_SAMPLER_DIM_MS) {
+      if (sampler_dim == GLSL_SAMPLER_DIM_MS) {
          texop = nir_texop_txf_ms;
       } else {
          texop = nir_texop_txf;
index a645149008125af87499d6d9f7d6831ca0d0a6f6..cf67893c6c86c65268a43afa951a80bc89ea4ae6 100644 (file)
@@ -315,7 +315,6 @@ vtn_cfg_handle_prepass_instruction(struct vtn_builder *b, SpvOp opcode,
             vtn_push_value(b, w[2], vtn_value_type_sampled_image);
 
          val->sampled_image = ralloc(b, struct vtn_sampled_image);
-         val->sampled_image->type = type;
 
          struct vtn_type *sampler_type = rzalloc(b, struct vtn_type);
          sampler_type->base_type = vtn_base_type_sampler;
index db6242fa85a58b5537783615d3b4d89d6e46895c..7c7527582b4c3326a008607c982de62afff6a533 100644 (file)
@@ -537,7 +537,6 @@ struct vtn_image_pointer {
 };
 
 struct vtn_sampled_image {
-   struct vtn_type *type;
    struct vtn_pointer *image; /* Image or array of images */
    struct vtn_pointer *sampler; /* Sampler */
 };
index af611b68b13ba5401dcab991ae33e37e807f1eee..1028199d31065313e1d6d9e480c9a3070d00dae8 100644 (file)
@@ -2490,7 +2490,6 @@ vtn_handle_variables(struct vtn_builder *b, SpvOp opcode,
          struct vtn_value *val =
             vtn_push_value(b, w[2], vtn_value_type_sampled_image);
          val->sampled_image = ralloc(b, struct vtn_sampled_image);
-         val->sampled_image->type = base_val->sampled_image->type;
          val->sampled_image->image =
             vtn_pointer_dereference(b, base_val->sampled_image->image, chain);
          val->sampled_image->sampler = base_val->sampled_image->sampler;