draw_pt.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  /*
00029   * Authors:
00030   *   Keith Whitwell <keith@tungstengraphics.com>
00031   */
00032 
00033 #ifndef DRAW_PT_H
00034 #define DRAW_PT_H
00035 
00036 #include "pipe/p_compiler.h"
00037 
00038 typedef unsigned (*pt_elt_func)( const void *elts, unsigned idx );
00039 
00040 struct draw_pt_middle_end;
00041 struct draw_context;
00042 
00043 
00044 #define PT_SHADE      0x1
00045 #define PT_CLIPTEST   0x2
00046 #define PT_PIPELINE   0x4
00047 #define PT_MAX_MIDDLE 0x8
00048 
00049 
00050 /* The "front end" - prepare sets of fetch, draw elements for the
00051  * middle end.
00052  *
00053  * Currenly one version of this:
00054  *    - vcache - catchall implementation, decomposes to TRI/LINE/POINT prims
00055  * Later:
00056  *    - varray, varray_split
00057  *    - velement, velement_split
00058  *
00059  * Currenly only using the vcache version.
00060  */
00061 struct draw_pt_front_end {
00062    void (*prepare)( struct draw_pt_front_end *,
00063                     unsigned prim,
00064                     struct draw_pt_middle_end *,
00065                     unsigned opt );
00066 
00067    void (*run)( struct draw_pt_front_end *,
00068                 pt_elt_func elt_func,
00069                 const void *elt_ptr,
00070                 unsigned count );
00071 
00072    void (*finish)( struct draw_pt_front_end * );
00073    void (*destroy)( struct draw_pt_front_end * );
00074 };
00075 
00076 
00077 /* The "middle end" - prepares actual hardware vertices for the
00078  * hardware backend.
00079  *
00080  * Currently two versions of this:
00081  *     - fetch, vertex shade, cliptest, prim-pipeline
00082  *     - fetch, emit (ie passthrough)
00083  */
00084 struct draw_pt_middle_end {
00085    void (*prepare)( struct draw_pt_middle_end *,
00086                     unsigned prim,
00087                     unsigned opt,
00088                     unsigned *max_vertices );
00089 
00090    void (*run)( struct draw_pt_middle_end *,
00091                 const unsigned *fetch_elts,
00092                 unsigned fetch_count,
00093                 const ushort *draw_elts,
00094                 unsigned draw_count );
00095 
00096    void (*run_linear)(struct draw_pt_middle_end *,
00097                       unsigned start,
00098                       unsigned count);
00099 
00100    /* Transform all vertices in a linear range and then draw them with
00101     * the supplied element list.  May fail and return FALSE.
00102     */
00103    boolean (*run_linear_elts)( struct draw_pt_middle_end *,
00104                             unsigned fetch_start,
00105                             unsigned fetch_count,
00106                             const ushort *draw_elts,
00107                             unsigned draw_count );
00108 
00109    int (*get_max_vertex_count)( struct draw_pt_middle_end * );
00110 
00111    void (*finish)( struct draw_pt_middle_end * );
00112    void (*destroy)( struct draw_pt_middle_end * );
00113 };
00114 
00115 
00116 /* The "back end" - supplied by the driver, defined in draw_vbuf.h.
00117  */
00118 struct vbuf_render;
00119 struct vertex_header;
00120 
00121 
00122 /* Helper functions.
00123  */
00124 pt_elt_func draw_pt_elt_func( struct draw_context *draw );
00125 const void *draw_pt_elt_ptr( struct draw_context *draw,
00126                              unsigned start );
00127 
00128 /* Frontends: 
00129  *
00130  * Currently only the general-purpose vcache implementation, could add
00131  * a special case for tiny vertex buffers.
00132  */
00133 struct draw_pt_front_end *draw_pt_vcache( struct draw_context *draw );
00134 struct draw_pt_front_end *draw_pt_varray(struct draw_context *draw);
00135 
00136 
00137 /* Middle-ends:
00138  *
00139  * Currently one general-purpose case which can do all possibilities,
00140  * at the slight expense of creating a vertex_header in some cases
00141  * unecessarily.
00142  *
00143  * The special case fetch_emit code avoids pipeline vertices
00144  * altogether and builds hardware vertices directly from API
00145  * vertex_elements.
00146  */
00147 struct draw_pt_middle_end *draw_pt_fetch_emit( struct draw_context *draw );
00148 struct draw_pt_middle_end *draw_pt_middle_fse( struct draw_context *draw );
00149 struct draw_pt_middle_end *draw_pt_fetch_pipeline_or_emit(struct draw_context *draw);
00150 
00151 
00152 /* More helpers:
00153  */
00154 boolean draw_pt_get_edgeflag( struct draw_context *draw,
00155                               unsigned idx );
00156 
00157 
00158 /*******************************************************************************
00159  * HW vertex emit:
00160  */
00161 struct pt_emit;
00162 
00163 void draw_pt_emit_prepare( struct pt_emit *emit,
00164                            unsigned prim,
00165                            unsigned *max_vertices );
00166 
00167 void draw_pt_emit( struct pt_emit *emit,
00168                    const float (*vertex_data)[4],
00169                    unsigned vertex_count,
00170                    unsigned stride,
00171                    const ushort *elts,
00172                    unsigned count );
00173 
00174 void draw_pt_emit_linear( struct pt_emit *emit,
00175                           const float (*vertex_data)[4],
00176                           unsigned vertex_count,
00177                           unsigned stride,
00178                           unsigned start,
00179                           unsigned count );
00180 
00181 void draw_pt_emit_destroy( struct pt_emit *emit );
00182 
00183 struct pt_emit *draw_pt_emit_create( struct draw_context *draw );
00184 
00185 
00186 /*******************************************************************************
00187  * API vertex fetch:
00188  */
00189 
00190 struct pt_fetch;
00191 void draw_pt_fetch_prepare( struct pt_fetch *fetch,
00192                             unsigned vertex_size );
00193 
00194 void draw_pt_fetch_run( struct pt_fetch *fetch,
00195                         const unsigned *elts,
00196                         unsigned count,
00197                         char *verts );
00198 
00199 void draw_pt_fetch_run_linear( struct pt_fetch *fetch,
00200                                unsigned start,
00201                                unsigned count,
00202                                char *verts );
00203 
00204 void draw_pt_fetch_destroy( struct pt_fetch *fetch );
00205 
00206 struct pt_fetch *draw_pt_fetch_create( struct draw_context *draw );
00207 
00208 /*******************************************************************************
00209  * Post-VS: cliptest, rhw, viewport
00210  */
00211 struct pt_post_vs;
00212 
00213 boolean draw_pt_post_vs_run( struct pt_post_vs *pvs,
00214                              struct vertex_header *pipeline_verts,
00215                              unsigned stride,
00216                              unsigned count );
00217 
00218 void draw_pt_post_vs_prepare( struct pt_post_vs *pvs,
00219                               boolean bypass_clipping,
00220                               boolean identity_viewport,
00221                               boolean opengl );
00222 
00223 struct pt_post_vs *draw_pt_post_vs_create( struct draw_context *draw );
00224 
00225 void draw_pt_post_vs_destroy( struct pt_post_vs *pvs );
00226 
00227 
00228 /*******************************************************************************
00229  * Utils: 
00230  */
00231 void draw_pt_split_prim(unsigned prim, unsigned *first, unsigned *incr);
00232 unsigned draw_pt_reduced_prim(unsigned prim);
00233 
00234 
00235 #endif

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