draw_private.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 
00040 #ifndef DRAW_PRIVATE_H
00041 #define DRAW_PRIVATE_H
00042 
00043 
00044 #include "pipe/p_state.h"
00045 #include "pipe/p_defines.h"
00046 
00047 #include "tgsi/tgsi_exec.h"
00048 #include "tgsi/tgsi_scan.h"
00049 
00050 
00051 struct pipe_context;
00052 struct gallivm_prog;
00053 struct gallivm_cpu_engine;
00054 struct draw_vertex_shader;
00055 struct draw_context;
00056 struct draw_stage;
00057 struct vbuf_render;
00058 
00059 
00064 struct vertex_header {
00065    unsigned clipmask:12;
00066    unsigned edgeflag:1;
00067    unsigned pad:3;
00068    unsigned vertex_id:16;
00069 
00070    float clip[4];
00071 
00072    /* This will probably become float (*data)[4] soon:
00073     */
00074    float data[][4];
00075 };
00076 
00077 /* NOTE: It should match vertex_id size above */
00078 #define UNDEFINED_VERTEX_ID 0xffff
00079 
00080 
00084 struct draw_context
00085 {
00087    struct {
00088       struct draw_stage *first;  
00090       struct draw_stage *validate; 
00091 
00092       /* stages (in logical order) */
00093       struct draw_stage *flatshade;
00094       struct draw_stage *clip;
00095       struct draw_stage *cull;
00096       struct draw_stage *twoside;
00097       struct draw_stage *offset;
00098       struct draw_stage *unfilled;
00099       struct draw_stage *stipple;
00100       struct draw_stage *aapoint;
00101       struct draw_stage *aaline;
00102       struct draw_stage *pstipple;
00103       struct draw_stage *wide_line;
00104       struct draw_stage *wide_point;
00105       struct draw_stage *rasterize;
00106 
00107       float wide_point_threshold; 
00108       float wide_line_threshold;  
00109       boolean line_stipple;       
00110       boolean point_sprite;       
00112       /* Temporary storage while the pipeline is being run:
00113        */
00114       char *verts;
00115       unsigned vertex_stride;
00116       unsigned vertex_count;
00117    } pipeline;
00118 
00119 
00120    struct vbuf_render *render;
00121 
00122    /* Support prototype passthrough path:
00123     */
00124    struct {
00125       struct {
00126          struct draw_pt_middle_end *fetch_emit;
00127          struct draw_pt_middle_end *fetch_shade_emit;
00128          struct draw_pt_middle_end *general;
00129       } middle;
00130 
00131       struct {
00132          struct draw_pt_front_end *vcache;
00133          struct draw_pt_front_end *varray;
00134       } front;
00135 
00136       struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
00137       unsigned nr_vertex_buffers;
00138 
00139       struct pipe_vertex_element vertex_element[PIPE_MAX_ATTRIBS];
00140       unsigned nr_vertex_elements;
00141 
00142       /* user-space vertex data, buffers */
00143       struct {
00144          const unsigned *edgeflag;
00145 
00147          const void *elts;
00149          unsigned eltSize;
00150          unsigned min_index;
00151          unsigned max_index;
00152          
00154          const void *vbuffer[PIPE_MAX_ATTRIBS];
00155          
00157          const void *constants;
00158       } user;
00159 
00160       boolean test_fse;         /* enable FSE even though its not correct (eg for softpipe) */
00161       boolean no_fse;           /* disable FSE even when it is correct */
00162    } pt;
00163 
00164    struct {
00165       boolean bypass_clipping;
00166       boolean bypass_vs;
00167    } driver;
00168 
00169    boolean flushing;         
00170    boolean suspend_flushing; 
00171    boolean bypass_clipping;  
00173    boolean force_passthrough; 
00175    double mrd;  
00177    /* pipe state that we need: */
00178    const struct pipe_rasterizer_state *rasterizer;
00179    struct pipe_viewport_state viewport;
00180    boolean identity_viewport;
00181 
00182    struct {
00183       struct draw_vertex_shader *vertex_shader;
00184       uint num_vs_outputs;  
00185       uint position_output;
00186 
00188       struct tgsi_exec_machine machine;
00189 
00190       /* This (and the tgsi_exec_machine struct) probably need to be moved somewhere private.
00191        */
00192       struct gallivm_cpu_engine *engine;   
00193 
00194       /* Here's another one:
00195        */
00196       struct aos_machine *aos_machine; 
00197 
00198 
00199       const float (*aligned_constants)[4];
00200 
00201       float (*aligned_constant_storage)[4];
00202       unsigned const_storage_size;
00203 
00204 
00205       struct translate *fetch;
00206       struct translate_cache *fetch_cache;
00207       struct translate *emit;
00208       struct translate_cache *emit_cache;
00209    } vs;
00210 
00211    /* Clip derived state:
00212     */
00213    float plane[12][4];
00214    unsigned nr_planes;
00215 
00216    /* If a prim stage introduces new vertex attributes, they'll be stored here
00217     */
00218    struct {
00219       uint semantic_name;
00220       uint semantic_index;
00221       int slot;
00222    } extra_vp_outputs;
00223 
00224    unsigned reduced_prim;
00225 
00226    void *driver_private;
00227 };
00228 
00229 
00230 /*******************************************************************************
00231  * Vertex shader code:
00232  */
00233 boolean draw_vs_init( struct draw_context *draw );
00234 void draw_vs_destroy( struct draw_context *draw );
00235 
00236 void draw_vs_set_viewport( struct draw_context *, 
00237                            const struct pipe_viewport_state * );
00238 
00239 void draw_vs_set_constants( struct draw_context *,
00240                             const float (*constants)[4],
00241                             unsigned size );
00242 
00243 
00244 
00245 
00246 /*******************************************************************************
00247  * Vertex processing (was passthrough) code:
00248  */
00249 boolean draw_pt_init( struct draw_context *draw );
00250 void draw_pt_destroy( struct draw_context *draw );
00251 void draw_pt_reset_vertex_ids( struct draw_context *draw );
00252 
00253 
00254 /*******************************************************************************
00255  * Primitive processing (pipeline) code: 
00256  */
00257 
00258 boolean draw_pipeline_init( struct draw_context *draw );
00259 void draw_pipeline_destroy( struct draw_context *draw );
00260 
00261 
00262 
00263 
00264 
00265 /* We use the top few bits in the elts[] parameter to convey a little
00266  * API information.  This limits the number of vertices we can address
00267  * to only 4096 -- if that becomes a problem, we can switch to 32-bit
00268  * draw indices.
00269  *
00270  * These flags expected at first vertex of lines & triangles when
00271  * unfilled and/or line stipple modes are operational.
00272  */
00273 #define DRAW_PIPE_MAX_VERTICES  (0x1<<12)
00274 #define DRAW_PIPE_EDGE_FLAG_0   (0x1<<12)
00275 #define DRAW_PIPE_EDGE_FLAG_1   (0x2<<12)
00276 #define DRAW_PIPE_EDGE_FLAG_2   (0x4<<12)
00277 #define DRAW_PIPE_EDGE_FLAG_ALL (0x7<<12)
00278 #define DRAW_PIPE_RESET_STIPPLE (0x8<<12)
00279 #define DRAW_PIPE_FLAG_MASK     (0xf<<12)
00280 
00281 void draw_pipeline_run( struct draw_context *draw,
00282                         unsigned prim,
00283                         struct vertex_header *vertices,
00284                         unsigned vertex_count,
00285                         unsigned stride,
00286                         const ushort *elts,
00287                         unsigned count );
00288 
00289 void draw_pipeline_run_linear( struct draw_context *draw,
00290                                unsigned prim,
00291                                struct vertex_header *vertices,
00292                                unsigned count,
00293                                unsigned stride );
00294 
00295 
00296 
00297 void draw_pipeline_flush( struct draw_context *draw, 
00298                           unsigned flags );
00299 
00300 
00301 
00302 /*******************************************************************************
00303  * Flushing 
00304  */
00305 
00306 #define DRAW_FLUSH_STATE_CHANGE              0x8
00307 #define DRAW_FLUSH_BACKEND                   0x10
00308 
00309 
00310 void draw_do_flush( struct draw_context *draw, unsigned flags );
00311 
00312 
00313 
00314 
00315 #endif /* DRAW_PRIVATE_H */

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