llvmpipe: add framebuffer fetching support (v1.1)
[mesa.git] / src / gallium / auxiliary / gallivm / lp_bld_tgsi.h
index d82044f770ff61185bfa1d739e661eedc1fac5ad..856cea40c55ebd600deb4a1e2835af2af642c1c4 100644 (file)
@@ -61,6 +61,7 @@ struct tgsi_full_declaration;
 struct tgsi_full_immediate;
 struct tgsi_full_instruction;
 struct tgsi_full_src_register;
+struct tgsi_full_dst_register;
 struct tgsi_opcode_info;
 struct tgsi_token;
 struct tgsi_shader_info;
@@ -171,10 +172,20 @@ struct lp_bld_tgsi_system_values {
    LLVMValueRef prim_id;
    LLVMValueRef basevertex;
    LLVMValueRef invocation_id;
+   LLVMValueRef draw_id;
    LLVMValueRef thread_id;
    LLVMValueRef block_id;
    LLVMValueRef grid_size;
    LLVMValueRef front_facing;
+   LLVMValueRef work_dim;
+   LLVMValueRef block_size;
+   LLVMValueRef tess_coord;
+   LLVMValueRef tess_outer;
+   LLVMValueRef tess_inner;
+   LLVMValueRef vertices_in;
+   LLVMValueRef sample_id;
+   LLVMValueRef sample_pos;
+   LLVMValueRef sample_mask_in;
 };
 
 
@@ -233,6 +244,20 @@ struct lp_build_image_soa
                        const struct lp_sampler_size_query_params *params);
 };
 
+struct lp_build_fs_iface;
+struct lp_build_fs_iface {
+   LLVMValueRef (*interp_fn)(const struct lp_build_fs_iface *iface,
+                             struct lp_build_context *bld,
+                             unsigned attrib, unsigned chan,
+                             bool centroid, bool sample,
+                             LLVMValueRef indir_index, LLVMValueRef offsets[2]);
+
+   void (*fb_fetch)(const struct lp_build_fs_iface *iface,
+                    struct lp_build_context *bld,
+                    unsigned cbuf,
+                    LLVMValueRef result[4]);
+};
+
 void
 lp_build_tgsi_info(const struct tgsi_token *tokens,
                    struct lp_tgsi_info *info);
@@ -250,11 +275,16 @@ struct lp_build_tgsi_params {
    const struct lp_build_sampler_soa *sampler;
    const struct tgsi_shader_info *info;
    const struct lp_build_gs_iface *gs_iface;
+   const struct lp_build_tcs_iface *tcs_iface;
+   const struct lp_build_tes_iface *tes_iface;
    LLVMValueRef ssbo_ptr;
    LLVMValueRef ssbo_sizes_ptr;
    const struct lp_build_image_soa *image;
    LLVMValueRef shared_ptr;
    const struct lp_build_coro_suspend_info *coro;
+   LLVMValueRef kernel_args;
+   const struct lp_build_fs_iface *fs_iface;
+   unsigned gs_vertex_streams;
 };
 
 void
@@ -298,6 +328,14 @@ typedef LLVMValueRef (*lp_build_emit_fetch_fn)(struct lp_build_tgsi_context *,
                                         enum tgsi_opcode_type,
                                         unsigned);
 
+typedef void (*lp_build_emit_store_reg_fn)(struct lp_build_tgsi_context *,
+                              enum tgsi_opcode_type,
+                              const struct tgsi_full_dst_register *,
+                              unsigned,
+                              unsigned,
+                              LLVMValueRef,
+                              LLVMValueRef);
+
 struct lp_build_tgsi_context
 {
    struct lp_build_context base;
@@ -327,6 +365,7 @@ struct lp_build_tgsi_context
    const struct tgsi_shader_info *info;
 
    lp_build_emit_fetch_fn emit_fetch_funcs[TGSI_FILE_COUNT];
+   lp_build_emit_store_reg_fn emit_store_reg_funcs[TGSI_FILE_COUNT];
 
    LLVMValueRef (*emit_swizzle)(struct lp_build_tgsi_context *,
                          LLVMValueRef, unsigned, unsigned, unsigned, unsigned);
@@ -367,6 +406,12 @@ struct lp_build_tgsi_context
      */
    void (*emit_prologue)(struct lp_build_tgsi_context*);
 
+   /** This function allows the user to insert some instructions after
+     * declarations section, but before any other code.
+     * It is optional and does not need to be implemented.
+     */
+   void (*emit_prologue_post_decl)(struct lp_build_tgsi_context*);
+
    /** This function allows the user to insert some instructions at the end of
      * the program.  This callback is intended to be used for emitting
      * instructions to handle the export for the output registers, but it can
@@ -389,16 +434,68 @@ struct lp_build_gs_iface
                        struct lp_build_context * bld,
                        LLVMValueRef (*outputs)[4],
                        LLVMValueRef emitted_vertices_vec,
-                       LLVMValueRef stream_id);
+                       LLVMValueRef mask_vec, LLVMValueRef stream_id);
    void (*end_primitive)(const struct lp_build_gs_iface *gs_iface,
                          struct lp_build_context * bld,
                          LLVMValueRef total_emitted_vertices_vec,
                          LLVMValueRef verts_per_prim_vec,
                          LLVMValueRef emitted_prims_vec,
-                         LLVMValueRef mask_vec);
+                         LLVMValueRef mask_vec, unsigned stream);
    void (*gs_epilogue)(const struct lp_build_gs_iface *gs_iface,
                        LLVMValueRef total_emitted_vertices_vec,
-                       LLVMValueRef emitted_prims_vec);
+                       LLVMValueRef emitted_prims_vec, unsigned stream);
+};
+
+struct lp_build_tcs_iface
+{
+   void (*emit_prologue)(struct lp_build_context * bld);
+   void (*emit_epilogue)(struct lp_build_context * bld);
+   void (*emit_barrier)(struct lp_build_context *bld_base);
+
+   void (*emit_store_output)(const struct lp_build_tcs_iface *tcs_iface,
+                             struct lp_build_context * bld,
+                             unsigned name,
+                             boolean is_vindex_indirect,
+                             LLVMValueRef vertex_index,
+                             boolean is_aindex_indirect,
+                             LLVMValueRef attrib_index,
+                             LLVMValueRef swizzle_index,
+                             LLVMValueRef value,
+                             LLVMValueRef mask_vec);
+
+   LLVMValueRef (*emit_fetch_input)(const struct lp_build_tcs_iface *tcs_iface,
+                                    struct lp_build_context * bld,
+                                    boolean is_vindex_indirect,
+                                    LLVMValueRef vertex_index,
+                                    boolean is_aindex_indirect,
+                                    LLVMValueRef attrib_index,
+                                    LLVMValueRef swizzle_index);
+
+   LLVMValueRef (*emit_fetch_output)(const struct lp_build_tcs_iface *tcs_iface,
+                                    struct lp_build_context * bld,
+                                    boolean is_vindex_indirect,
+                                    LLVMValueRef vertex_index,
+                                    boolean is_aindex_indirect,
+                                    LLVMValueRef attrib_index,
+                                    LLVMValueRef swizzle_index,
+                                    uint32_t name);
+};
+
+struct lp_build_tes_iface
+{
+   LLVMValueRef (*fetch_vertex_input)(const struct lp_build_tes_iface *tes_iface,
+                                      struct lp_build_context * bld,
+                                      boolean is_vindex_indirect,
+                                      LLVMValueRef vertex_index,
+                                      boolean is_aindex_indirect,
+                                      LLVMValueRef attrib_index,
+                                      LLVMValueRef swizzle_index);
+
+   LLVMValueRef (*fetch_patch_input)(const struct lp_build_tes_iface *tes_iface,
+                                     struct lp_build_context * bld,
+                                     boolean is_aindex_indirect,
+                                     LLVMValueRef attrib_index,
+                                     LLVMValueRef swizzle_index);
 };
 
 struct lp_build_tgsi_soa_context
@@ -409,6 +506,9 @@ struct lp_build_tgsi_soa_context
    struct lp_build_context elem_bld;
 
    const struct lp_build_gs_iface *gs_iface;
+   const struct lp_build_tcs_iface *tcs_iface;
+   const struct lp_build_tes_iface *tes_iface;
+
    LLVMValueRef emitted_prims_vec_ptr;
    LLVMValueRef total_emitted_vertices_vec_ptr;
    LLVMValueRef emitted_vertices_vec_ptr;