nir/spirv: add gl_spirv_validation method
[mesa.git] / src / compiler / spirv / vtn_private.h
index 374643a7a84db702b9853440bb85e3aed29bb32b..d8a00f99b97e865052505ec92e37b09cec62cc6b 100644 (file)
@@ -274,8 +274,8 @@ struct vtn_type {
 
    const struct glsl_type *type;
 
-   /* The value that declares this type.  Used for finding decorations */
-   struct vtn_value *val;
+   /* The SPIR-V id of the given type. */
+   uint32_t id;
 
    /* Specifies the length of complex types.
     *
@@ -365,6 +365,9 @@ struct vtn_type {
    };
 };
 
+bool vtn_types_compatible(struct vtn_builder *b,
+                          struct vtn_type *t1, struct vtn_type *t2);
+
 struct vtn_variable;
 
 enum vtn_access_mode {
@@ -636,6 +639,12 @@ bool
 vtn_set_instruction_result_type(struct vtn_builder *b, SpvOp opcode,
                                 const uint32_t *w, unsigned count);
 
+static inline nir_constant *
+vtn_constant_value(struct vtn_builder *b, uint32_t value_id)
+{
+   return vtn_value(b, value_id, vtn_value_type_constant)->constant;
+}
+
 struct vtn_ssa_value *vtn_ssa_value(struct vtn_builder *b, uint32_t value_id);
 
 struct vtn_ssa_value *vtn_create_ssa_value(struct vtn_builder *b,
@@ -699,14 +708,27 @@ void vtn_foreach_execution_mode(struct vtn_builder *b, struct vtn_value *value,
 
 nir_op vtn_nir_alu_op_for_spirv_opcode(struct vtn_builder *b,
                                        SpvOp opcode, bool *swap,
-                                       nir_alu_type src, nir_alu_type dst);
+                                       unsigned src_bit_size, unsigned dst_bit_size);
 
 void vtn_handle_alu(struct vtn_builder *b, SpvOp opcode,
                     const uint32_t *w, unsigned count);
 
+void vtn_handle_subgroup(struct vtn_builder *b, SpvOp opcode,
+                         const uint32_t *w, unsigned count);
+
 bool vtn_handle_glsl450_instruction(struct vtn_builder *b, uint32_t ext_opcode,
                                     const uint32_t *words, unsigned count);
 
+struct vtn_builder* vtn_create_builder(const uint32_t *words, size_t word_count,
+                                       gl_shader_stage stage, const char *entry_point_name,
+                                       const struct spirv_to_nir_options *options);
+
+void vtn_handle_entry_point(struct vtn_builder *b, const uint32_t *w,
+                            unsigned count);
+
+void vtn_handle_decoration(struct vtn_builder *b, SpvOp opcode,
+                           const uint32_t *w, unsigned count);
+
 static inline uint32_t
 vtn_align_u32(uint32_t v, uint32_t a)
 {
@@ -720,4 +742,9 @@ vtn_u64_literal(const uint32_t *w)
    return (uint64_t)w[1] << 32 | w[0];
 }
 
+bool vtn_handle_amd_gcn_shader_instruction(struct vtn_builder *b, uint32_t ext_opcode,
+                                           const uint32_t *words, unsigned count);
+
+bool vtn_handle_amd_shader_trinary_minmax_instruction(struct vtn_builder *b, uint32_t ext_opcode,
+                                                     const uint32_t *words, unsigned count);
 #endif /* _VTN_PRIVATE_H_ */