draw_vs.h

Go to the documentation of this file.
00001 /**************************************************************************
00002  * 
00003  * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  * 
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  * 
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  * 
00026  **************************************************************************/
00027 
00028 /* Authors:  Keith Whitwell <keith@tungstengraphics.com>
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;     /* output format */
00051    unsigned vs_output:8;        /* which vertex shader output is this? */
00052    unsigned offset:24;          /* offset into output vertex */
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;      /* max2(nr_inputs, nr_outputs) */
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    /* This member will disappear shortly:
00105     */
00106    struct pipe_shader_state   state;
00107 
00108    struct tgsi_shader_info info;
00109    unsigned position_output;
00110 
00111    /* Extracted from shader:
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    /* Run the shader - this interface will get cleaned up in the
00128     * future:
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  * Internal functions:
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  * Helpers for vs implementations that don't do their own fetch/emit varients.
00176  * Means these can be shared between shaders.
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

Generated on Tue Sep 29 06:25:14 2009 for Gallium3D by  doxygen 1.5.4