00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
00028 
00029 
00030 
00031 #ifndef DRAW_VS_H
00032 #define DRAW_VS_H
00033 
00034 #include "draw_context.h"
00035 #include "draw_private.h"
00036 
00037 
00038 struct draw_context;
00039 struct pipe_shader_state;
00040 
00041 struct draw_varient_input 
00042 {
00043    enum pipe_format format;
00044    unsigned buffer;
00045    unsigned offset; 
00046 };
00047 
00048 struct draw_varient_output
00049 {
00050    enum pipe_format format;     
00051    unsigned vs_output:8;        
00052    unsigned offset:24;          
00053 };
00054 
00055 struct draw_varient_element {
00056    struct draw_varient_input in;
00057    struct draw_varient_output out;
00058 };
00059 
00060 struct draw_vs_varient_key {
00061    unsigned output_stride;
00062    unsigned nr_elements:8;      
00063    unsigned nr_inputs:8;
00064    unsigned nr_outputs:8;
00065    unsigned viewport:1;
00066    unsigned clip:1;
00067    unsigned const_vbuffers:5;
00068    struct draw_varient_element element[PIPE_MAX_ATTRIBS];
00069 };
00070 
00071 struct draw_vs_varient;
00072 
00073 
00074 struct draw_vs_varient {
00075    struct draw_vs_varient_key key;
00076 
00077    struct draw_vertex_shader *vs;
00078 
00079    void (*set_buffer)( struct draw_vs_varient *,
00080                       unsigned i,
00081                       const void *ptr,
00082                       unsigned stride );
00083 
00084    void (PIPE_CDECL *run_linear)( struct draw_vs_varient *shader,
00085                                   unsigned start,
00086                                   unsigned count,
00087                                   void *output_buffer );
00088 
00089    void (PIPE_CDECL *run_elts)( struct draw_vs_varient *shader,
00090                                 const unsigned *elts,
00091                                 unsigned count,
00092                                 void *output_buffer );
00093 
00094    void (*destroy)( struct draw_vs_varient * );
00095 };
00096 
00097 
00101 struct draw_vertex_shader {
00102    struct draw_context *draw;
00103 
00104    
00105 
00106    struct pipe_shader_state   state;
00107 
00108    struct tgsi_shader_info info;
00109    unsigned position_output;
00110 
00111    
00112 
00113    const float (*immediates)[4];
00114 
00115    
00116 
00117    struct draw_vs_varient *varient[16];
00118    unsigned nr_varients;
00119    unsigned last_varient;
00120    struct draw_vs_varient *(*create_varient)( struct draw_vertex_shader *shader,
00121                                               const struct draw_vs_varient_key *key );
00122 
00123 
00124    void (*prepare)( struct draw_vertex_shader *shader,
00125                     struct draw_context *draw );
00126 
00127    
00128 
00129 
00130    void (*run_linear)( struct draw_vertex_shader *shader,
00131                        const float (*input)[4],
00132                        float (*output)[4],
00133                        const float (*constants)[4],
00134                        unsigned count,
00135                        unsigned input_stride,
00136                        unsigned output_stride );
00137 
00138 
00139    void (*delete)( struct draw_vertex_shader * );
00140 };
00141 
00142 
00143 struct draw_vs_varient *
00144 draw_vs_lookup_varient( struct draw_vertex_shader *base,
00145                         const struct draw_vs_varient_key *key );
00146 
00147 
00148 
00149 
00150 
00151 
00152 struct draw_vertex_shader *
00153 draw_create_vs_exec(struct draw_context *draw,
00154                     const struct pipe_shader_state *templ);
00155 
00156 struct draw_vertex_shader *
00157 draw_create_vs_sse(struct draw_context *draw,
00158                    const struct pipe_shader_state *templ);
00159 
00160 struct draw_vertex_shader *
00161 draw_create_vs_llvm(struct draw_context *draw,
00162                     const struct pipe_shader_state *templ);
00163 
00164 
00165 
00166 struct draw_vs_varient_key;
00167 struct draw_vertex_shader;
00168 
00169 struct draw_vs_varient *draw_vs_varient_aos_sse( struct draw_vertex_shader *vs,
00170                                                  const struct draw_vs_varient_key *key );
00171 
00172 
00173 
00174 
00175 
00176 
00177 
00178 struct translate;
00179 struct translate_key;
00180 
00181 struct translate *draw_vs_get_fetch( struct draw_context *draw,
00182                                      struct translate_key *key );
00183 
00184 
00185 struct translate *draw_vs_get_emit( struct draw_context *draw,
00186                                     struct translate_key *key );
00187 
00188 struct draw_vs_varient *draw_vs_varient_generic( struct draw_vertex_shader *vs,
00189                                                  const struct draw_vs_varient_key *key );
00190 
00191 
00192 
00193 static INLINE int draw_vs_varient_keysize( const struct draw_vs_varient_key *key )
00194 {
00195    return 2 * sizeof(int) + key->nr_elements * sizeof(struct draw_varient_element);
00196 }
00197 
00198 static INLINE int draw_vs_varient_key_compare( const struct draw_vs_varient_key *a,
00199                                          const struct draw_vs_varient_key *b )
00200 {
00201    int keysize = draw_vs_varient_keysize(a);
00202    return memcmp(a, b, keysize);
00203 }
00204 
00205 
00206 struct aos_machine *draw_vs_aos_machine( void );
00207 void draw_vs_aos_machine_destroy( struct aos_machine *machine );
00208 
00209 void draw_vs_aos_machine_constants( struct aos_machine *machine,
00210                                     const float (*constants)[4] );
00211 
00212 void draw_vs_aos_machine_viewport( struct aos_machine *machine,
00213                                    const struct pipe_viewport_state *viewport );
00214 
00215 
00216 #define MAX_TGSI_VERTICES 4
00217    
00218 
00219 
00220 #endif