spirv: Convert the supported_extensions struct to spirv_options
[mesa.git] / src / compiler / spirv / vtn_private.h
index 2f96c0904ac45c53ac1d6103a52b9cc347800097..b43802940485bddec68fe214381b6cde31af6868 100644 (file)
@@ -159,6 +159,9 @@ struct vtn_block {
 struct vtn_function {
    struct exec_node node;
 
+   bool referenced;
+   bool emitted;
+
    nir_function_impl *impl;
    struct vtn_block *start_block;
 
@@ -369,6 +372,13 @@ struct vtn_pointer {
    struct nir_ssa_def *offset;
 };
 
+static inline bool
+vtn_pointer_uses_ssa_offset(struct vtn_pointer *ptr)
+{
+   return ptr->mode == vtn_variable_mode_ubo ||
+          ptr->mode == vtn_variable_mode_ssbo;
+}
+
 struct vtn_variable {
    enum vtn_variable_mode mode;
 
@@ -404,6 +414,7 @@ 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 */
 };
@@ -456,8 +467,7 @@ struct vtn_builder {
    nir_builder nb;
 
    nir_shader *shader;
-   nir_function_impl *impl;
-   const struct nir_spirv_supported_extensions *ext;
+   const struct spirv_to_nir_options *options;
    struct vtn_block *block;
 
    /* Current file, line, and column.  Useful for debugging.  Set
@@ -501,6 +511,12 @@ struct vtn_builder {
    bool has_loop_continue;
 };
 
+nir_ssa_def *
+vtn_pointer_to_ssa(struct vtn_builder *b, struct vtn_pointer *ptr);
+struct vtn_pointer *
+vtn_pointer_from_ssa(struct vtn_builder *b, nir_ssa_def *ssa,
+                     struct vtn_type *ptr_type);
+
 static inline struct vtn_value *
 vtn_push_value(struct vtn_builder *b, uint32_t value_id,
                enum vtn_value_type value_type)
@@ -513,6 +529,21 @@ vtn_push_value(struct vtn_builder *b, uint32_t value_id,
    return &b->values[value_id];
 }
 
+static inline struct vtn_value *
+vtn_push_ssa(struct vtn_builder *b, uint32_t value_id,
+             struct vtn_type *type, struct vtn_ssa_value *ssa)
+{
+   struct vtn_value *val;
+   if (type->base_type == vtn_base_type_pointer) {
+      val = vtn_push_value(b, value_id, vtn_value_type_pointer);
+      val->pointer = vtn_pointer_from_ssa(b, ssa->def, type);
+   } else {
+      val = vtn_push_value(b, value_id, vtn_value_type_ssa);
+      val->ssa = ssa;
+   }
+   return val;
+}
+
 static inline struct vtn_value *
 vtn_untyped_value(struct vtn_builder *b, uint32_t value_id)
 {