1 #ifndef LP_STATE_SETUP_H
2 #define LP_STATE_SETUP_H
3 
4 #include "lp_bld_interp.h"
5 
6 
7 struct llvmpipe_context;
8 struct lp_setup_variant;
9 
10 struct lp_setup_variant_list_item
11 {
12    struct lp_setup_variant *base;
13    struct lp_setup_variant_list_item *next, *prev;
14 };
15 
16 
17 struct lp_setup_variant_key {
18    unsigned size:16;
19    unsigned num_inputs:8;
20    int color_slot:8;
21    int bcolor_slot:8;
22    int spec_slot:8;
23    int bspec_slot:8;
24    unsigned flatshade_first:1;
25    unsigned pixel_center_half:1;
26    unsigned twoside:1;
27    unsigned floating_point_depth:1;
28    unsigned uses_constant_interp:1;
29    unsigned multisample:1;
30    unsigned pad:3;
31 
32    /* TODO: get those floats out of the key and use a jit_context for setup */
33    float pgon_offset_units;
34    float pgon_offset_scale;
35    float pgon_offset_clamp;
36    struct lp_shader_input inputs[PIPE_MAX_SHADER_INPUTS];
37 };
38 
39 
40 typedef void (*lp_jit_setup_triangle)( const float (*v0)[4],
41 				       const float (*v1)[4],
42 				       const float (*v2)[4],
43 				       boolean front_facing,
44 				       float (*a0)[4],
45 				       float (*dadx)[4],
46 				       float (*dady)[4],
47                                        const struct lp_setup_variant_key *key );
48 
49 
50 
51 
52 /* At this stage, for a given variant key, we create a
53  * draw_vertex_info struct telling the draw module how to format the
54  * vertices, and an llvm-generated function which calculates the
55  * attribute interpolants (a0, dadx, dady) from three of those
56  * vertices.
57  */
58 struct lp_setup_variant {
59    struct lp_setup_variant_key key;
60 
61    struct lp_setup_variant_list_item list_item_global;
62 
63    struct gallivm_state *gallivm;
64 
65    /* XXX: this is a pointer to the LLVM IR.  Once jit_function is
66     * generated, we never need to use the IR again - need to find a
67     * way to release this data without destroying the generated
68     * assembly.
69     */
70    LLVMValueRef function;
71 
72    /* The actual generated setup function:
73     */
74    lp_jit_setup_triangle jit_function;
75 
76    unsigned no;
77 };
78 
79 void lp_delete_setup_variants(struct llvmpipe_context *lp);
80 
81 void
82 lp_dump_setup_coef( const struct lp_setup_variant_key *key,
83 		    const float (*sa0)[4],
84 		    const float (*sdadx)[4],
85 		    const float (*sdady)[4]);
86 
87 #endif
88