panfrost: add missing dependency on midgard_pack.h
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_nir.h
index 194b109760c47af59952e581b6681e2d49e3c1d6..7f29575bad553283310de5460df517c131943d10 100644 (file)
@@ -45,6 +45,10 @@ struct lp_build_nir_context
    struct lp_build_context base;
    struct lp_build_context uint_bld;
    struct lp_build_context int_bld;
+   struct lp_build_context uint8_bld;
+   struct lp_build_context int8_bld;
+   struct lp_build_context uint16_bld;
+   struct lp_build_context int16_bld;
    struct lp_build_context dbl_bld;
    struct lp_build_context uint64_bld;
    struct lp_build_context int64_bld;
@@ -59,12 +63,37 @@ struct lp_build_nir_context
                     unsigned nc,
                     unsigned bit_size,
                     bool offset_is_uniform,
-                    LLVMValueRef index, LLVMValueRef offset, LLVMValueRef result[4]);
+                    LLVMValueRef index, LLVMValueRef offset, LLVMValueRef result[NIR_MAX_VEC_COMPONENTS]);
+
+   void (*load_kernel_arg)(struct lp_build_nir_context *bld_base,
+                           unsigned nc,
+                           unsigned bit_size,
+                           unsigned offset_bit_size,
+                           bool offset_is_uniform,
+                           LLVMValueRef offset, LLVMValueRef result[NIR_MAX_VEC_COMPONENTS]);
+
+   void (*load_global)(struct lp_build_nir_context *bld_base,
+                       unsigned nc, unsigned bit_size,
+                       unsigned offset_bit_size,
+                       LLVMValueRef offset, LLVMValueRef result[NIR_MAX_VEC_COMPONENTS]);
+
+   void (*store_global)(struct lp_build_nir_context *bld_base,
+                        unsigned writemask,
+                        unsigned nc, unsigned bit_size,
+                        unsigned addr_bit_size,
+                        LLVMValueRef addr, LLVMValueRef dst);
+
+   void (*atomic_global)(struct lp_build_nir_context *bld_base,
+                         nir_intrinsic_op op,
+                         unsigned addr_bit_size,
+                         LLVMValueRef addr,
+                         LLVMValueRef val, LLVMValueRef val2,
+                         LLVMValueRef *result);
 
    /* for SSBO and shared memory */
    void (*load_mem)(struct lp_build_nir_context *bld_base,
                     unsigned nc, unsigned bit_size,
-                    LLVMValueRef index, LLVMValueRef offset, LLVMValueRef result[4]);
+                    LLVMValueRef index, LLVMValueRef offset, LLVMValueRef result[NIR_MAX_VEC_COMPONENTS]);
    void (*store_mem)(struct lp_build_nir_context *bld_base,
                      unsigned writemask, unsigned nc, unsigned bit_size,
                      LLVMValueRef index, LLVMValueRef offset, LLVMValueRef dst);
@@ -90,16 +119,20 @@ struct lp_build_nir_context
                     unsigned bit_size,
                     nir_variable *var,
                     unsigned vertex_index,
+                    LLVMValueRef indir_vertex_index,
                     unsigned const_index,
                     LLVMValueRef indir_index,
-                    LLVMValueRef result[4]);
+                    LLVMValueRef result[NIR_MAX_VEC_COMPONENTS]);
    void (*store_var)(struct lp_build_nir_context *bld_base,
                      nir_variable_mode deref_mode,
-                     unsigned bit_size,
                      unsigned num_components,
+                     unsigned bit_size,
+                     nir_variable *var,
                      unsigned writemask,
+                     LLVMValueRef indir_vertex_index,
                      unsigned const_index,
-                     nir_variable *var, LLVMValueRef dst);
+                     LLVMValueRef indir_index,
+                     LLVMValueRef dst);
 
    LLVMValueRef (*load_reg)(struct lp_build_nir_context *bld_base,
                             struct lp_build_context *reg_bld,
@@ -112,7 +145,7 @@ struct lp_build_nir_context
                      unsigned writemask,
                      LLVMValueRef indir_src,
                      LLVMValueRef reg_storage,
-                     LLVMValueRef dst[4]);
+                     LLVMValueRef dst[NIR_MAX_VEC_COMPONENTS]);
 
    void (*emit_var_decl)(struct lp_build_nir_context *bld_base,
                          nir_variable *var);
@@ -125,7 +158,7 @@ struct lp_build_nir_context
 
    void (*sysval_intrin)(struct lp_build_nir_context *bld_base,
                          nir_intrinsic_instr *instr,
-                         LLVMValueRef result[4]);
+                         LLVMValueRef result[NIR_MAX_VEC_COMPONENTS]);
    void (*discard)(struct lp_build_nir_context *bld_base,
                    LLVMValueRef cond);
 
@@ -139,6 +172,17 @@ struct lp_build_nir_context
 
    void (*emit_vertex)(struct lp_build_nir_context *bld_base, uint32_t stream_id);
    void (*end_primitive)(struct lp_build_nir_context *bld_base, uint32_t stream_id);
+
+   void (*vote)(struct lp_build_nir_context *bld_base, LLVMValueRef src, nir_intrinsic_instr *instr, LLVMValueRef dst[4]);
+   void (*helper_invocation)(struct lp_build_nir_context *bld_base, LLVMValueRef *dst);
+
+   void (*interp_at)(struct lp_build_nir_context *bld_base,
+                     unsigned num_components,
+                     nir_variable *var,
+                     bool centroid, bool sample,
+                     unsigned const_index,
+                     LLVMValueRef indir_index,
+                     LLVMValueRef offsets[2], LLVMValueRef dst[4]);
 //   LLVMValueRef main_function
 };
 
@@ -172,9 +216,12 @@ struct lp_build_nir_soa_context
    const struct lp_build_image_soa *image;
 
    const struct lp_build_gs_iface *gs_iface;
-   LLVMValueRef emitted_prims_vec_ptr;
-   LLVMValueRef total_emitted_vertices_vec_ptr;
-   LLVMValueRef emitted_vertices_vec_ptr;
+   const struct lp_build_tcs_iface *tcs_iface;
+   const struct lp_build_tes_iface *tes_iface;
+   const struct lp_build_fs_iface *fs_iface;
+   LLVMValueRef emitted_prims_vec_ptr[PIPE_MAX_VERTEX_STREAMS];
+   LLVMValueRef total_emitted_vertices_vec_ptr[PIPE_MAX_VERTEX_STREAMS];
+   LLVMValueRef emitted_vertices_vec_ptr[PIPE_MAX_VERTEX_STREAMS];
    LLVMValueRef max_output_vertices_vec;
    struct lp_bld_tgsi_system_values system_values;
 
@@ -186,6 +233,9 @@ struct lp_build_nir_soa_context
     * set. The inputs[] array above is unused then.
     */
    LLVMValueRef inputs_array;
+
+   LLVMValueRef kernel_args_ptr;
+   unsigned gs_vertex_streams;
 };
 
 bool
@@ -209,4 +259,36 @@ lp_nir_array_build_gather_values(LLVMBuilderRef builder,
    return arr;
 }
 
+
+static inline struct lp_build_context *get_int_bld(struct lp_build_nir_context *bld_base,
+                                                   bool is_unsigned,
+                                                   unsigned op_bit_size)
+{
+   if (is_unsigned) {
+      switch (op_bit_size) {
+      case 64:
+         return &bld_base->uint64_bld;
+      case 32:
+      default:
+         return &bld_base->uint_bld;
+      case 16:
+         return &bld_base->uint16_bld;
+      case 8:
+         return &bld_base->uint8_bld;
+      }
+   } else {
+      switch (op_bit_size) {
+      case 64:
+         return &bld_base->int64_bld;
+      default:
+      case 32:
+         return &bld_base->int_bld;
+      case 16:
+         return &bld_base->int16_bld;
+      case 8:
+         return &bld_base->int8_bld;
+      }
+   }
+}
+
 #endif