ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

t_dd_dmatmp2.h
Go to the documentation of this file.
00001 /*
00002  * Mesa 3-D graphics library
00003  * Version:  6.5.1
00004  *
00005  * Copyright (C) 1999-2006  Brian Paul   All Rights Reserved.
00006  *
00007  * Permission is hereby granted, free of charge, to any person obtaining a
00008  * copy of this software and associated documentation files (the "Software"),
00009  * to deal in the Software without restriction, including without limitation
00010  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
00011  * and/or sell copies of the Software, and to permit persons to whom the
00012  * Software is furnished to do so, subject to the following conditions:
00013  *
00014  * The above copyright notice and this permission notice shall be included
00015  * in all copies or substantial portions of the Software.
00016  *
00017  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00018  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
00019  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
00020  * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
00021  * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
00022  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00023  *
00024  * Authors:
00025  *    Keith Whitwell <keith@tungstengraphics.com>
00026  */
00027 
00028 
00038 #if !HAVE_TRIANGLES || !HAVE_POINTS || !HAVE_LINES
00039 #error "must have points, lines & triangles to use render template"
00040 #endif
00041 
00042 #if !HAVE_TRI_STRIPS || !HAVE_TRI_FANS
00043 #error "must have tri strip and fans to use render template"
00044 #endif
00045 
00046 #if !HAVE_LINE_STRIPS
00047 #error "must have line strips to use render template"
00048 #endif
00049 
00050 #if !HAVE_POLYGONS
00051 #error "must have polygons to use render template"
00052 #endif
00053 
00054 #if !HAVE_ELTS
00055 #error "must have elts to use render template"
00056 #endif
00057 
00058 
00059 #ifndef EMIT_TWO_ELTS
00060 #define EMIT_TWO_ELTS( dest, offset, elt0, elt1 )   \
00061 do {                        \
00062    (dest)[offset] = (elt0);             \
00063    (dest)[offset+1] = (elt1);           \
00064 } while (0)
00065 #endif
00066 
00067 
00068 /**********************************************************************/
00069 /*                  Render whole begin/end objects                    */
00070 /**********************************************************************/
00071 
00072 
00073 static ELT_TYPE *TAG(emit_elts)( GLcontext *ctx, 
00074                 ELT_TYPE *dest,
00075                 GLuint *elts, GLuint nr )
00076 {
00077    GLint i;
00078    LOCAL_VARS;
00079 
00080    for ( i = 0 ; i+1 < nr ; i+=2, elts += 2 ) {
00081       EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );
00082       dest += 2;
00083    }
00084    if (i < nr) {
00085       EMIT_ELT( dest, 0, elts[0] );
00086       dest += 1;
00087    }
00088    
00089    return dest;
00090 }
00091 
00092 static ELT_TYPE *TAG(emit_consecutive_elts)( GLcontext *ctx, 
00093                     ELT_TYPE *dest,
00094                     GLuint start, GLuint nr )
00095 {
00096    GLint i;
00097    LOCAL_VARS;
00098 
00099    for ( i = 0 ; i+1 < nr ; i+=2, start += 2 ) {
00100       EMIT_TWO_ELTS( dest, 0, start, start+1 );
00101       dest += 2;
00102    }
00103    if (i < nr) {
00104       EMIT_ELT( dest, 0, start );
00105       dest += 1;
00106    }
00107 
00108    return dest;
00109 }
00110 
00111 /***********************************************************************
00112  *                    Render non-indexed primitives.
00113  ***********************************************************************/
00114 
00115 
00116 
00117 static void TAG(render_points_verts)( GLcontext *ctx,
00118                       GLuint start,
00119                       GLuint count,
00120                       GLuint flags )
00121 {
00122    if (start < count) {
00123       LOCAL_VARS;
00124       if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00125       EMIT_PRIM( ctx, GL_POINTS, HW_POINTS, start, count );
00126    }
00127 }
00128 
00129 static void TAG(render_lines_verts)( GLcontext *ctx,
00130                      GLuint start,
00131                      GLuint count,
00132                      GLuint flags )
00133 {
00134    LOCAL_VARS;
00135    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00136    count -= (count-start) & 1;
00137 
00138    if (start+1 >= count)
00139       return;
00140 
00141    if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) {
00142       RESET_STIPPLE();
00143       AUTO_STIPPLE( GL_TRUE );
00144    }
00145       
00146    EMIT_PRIM( ctx, GL_LINES, HW_LINES, start, count );
00147 
00148    if ((flags & PRIM_END) && ctx->Line.StippleFlag)
00149       AUTO_STIPPLE( GL_FALSE );
00150 }
00151 
00152 
00153 static void TAG(render_line_strip_verts)( GLcontext *ctx,
00154                       GLuint start,
00155                       GLuint count,
00156                       GLuint flags )
00157 {
00158    LOCAL_VARS;
00159    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00160 
00161    if (start+1 >= count)
00162       return;
00163 
00164    if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)
00165       RESET_STIPPLE();
00166 
00167 
00168    if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES ))
00169    {   
00170       int dmasz = GET_MAX_HW_ELTS();
00171       GLuint j, nr;
00172 
00173       ELT_INIT( GL_LINES, HW_LINES );
00174 
00175       /* Emit whole number of lines in each full buffer.
00176        */
00177       dmasz = dmasz/2;
00178 
00179 
00180       for (j = start; j + 1 < count; j += nr - 1 ) {
00181      ELT_TYPE *dest;
00182      GLint i;
00183 
00184      nr = MIN2( dmasz, count - j );
00185      dest = ALLOC_ELTS( (nr-1)*2 );
00186         
00187      for ( i = j ; i+1 < j+nr ; i+=1 ) {
00188         EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );
00189         dest += 2;
00190      }
00191 
00192      CLOSE_ELTS();
00193       }
00194    }
00195    else
00196       EMIT_PRIM( ctx, GL_LINE_STRIP, HW_LINE_STRIP, start, count );
00197 }
00198 
00199 
00200 static void TAG(render_line_loop_verts)( GLcontext *ctx,
00201                      GLuint start,
00202                      GLuint count,
00203                      GLuint flags )
00204 {
00205    LOCAL_VARS;
00206    GLuint j, nr;
00207    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00208 
00209    if (flags & PRIM_BEGIN) {
00210       j = start;
00211       if (ctx->Line.StippleFlag)
00212      RESET_STIPPLE( );
00213    }
00214    else
00215       j = start + 1;
00216 
00217    if (flags & PRIM_END) {
00218 
00219       if (start+1 >= count)
00220      return;
00221 
00222       if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_LINES )) {
00223      int dmasz = GET_MAX_HW_ELTS();
00224 
00225      ELT_INIT( GL_LINES, HW_LINES );
00226 
00227      /* Emit whole number of lines in each full buffer.
00228       */
00229      dmasz = dmasz/2;
00230 
00231      /* Ensure last vertex doesn't wrap:
00232       */
00233      dmasz--;
00234 
00235      for (; j + 1 < count;  ) {
00236         GLint i;
00237         ELT_TYPE *dest;
00238 
00239         nr = MIN2( dmasz, count - j );
00240         dest = ALLOC_ELTS( nr*2 );  /* allocs room for 1 more line */
00241 
00242         for ( i = 0 ; i < nr - 1 ; i+=1 ) {
00243            EMIT_TWO_ELTS( dest, 0, (j+i), (j+i+1) );
00244            dest += 2;
00245         }
00246 
00247         j += nr - 1;
00248 
00249         /* Emit 1 more line into space alloced above */
00250         if (j + 1 >= count) {
00251            EMIT_TWO_ELTS( dest, 0, (j), (start) ); 
00252            dest += 2; 
00253         }
00254  
00255         CLOSE_ELTS();
00256      }
00257       }
00258       else
00259       {
00260      int dmasz = GET_MAX_HW_ELTS() - 1;
00261 
00262      ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );
00263 
00264      for ( ; j + 1 < count;  ) {
00265         nr = MIN2( dmasz, count - j );
00266         if (j + nr < count) {
00267            ELT_TYPE *dest = ALLOC_ELTS( nr );
00268            dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
00269            j += nr - 1;
00270            CLOSE_ELTS();
00271         }
00272         else if (nr) {
00273            ELT_TYPE *dest = ALLOC_ELTS( nr + 1 );
00274            dest = TAG(emit_consecutive_elts)( ctx, dest, j, nr );
00275            dest = TAG(emit_consecutive_elts)( ctx, dest, start, 1 );
00276            j += nr;
00277            CLOSE_ELTS();
00278         }
00279      }   
00280       }
00281    } else {
00282       TAG(render_line_strip_verts)( ctx, j, count, flags );
00283    }
00284 }
00285 
00286 
00287 static void TAG(render_triangles_verts)( GLcontext *ctx,
00288                      GLuint start,
00289                      GLuint count,
00290                      GLuint flags )
00291 {
00292    LOCAL_VARS;
00293    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00294 
00295    count -= (count-start)%3;
00296 
00297    if (start+2 >= count) {
00298       return;
00299    }
00300 
00301    /* need a PREFER_DISCRETE_ELT_PRIM here too..
00302     */
00303    EMIT_PRIM( ctx, GL_TRIANGLES, HW_TRIANGLES, start, count );
00304 }
00305 
00306 
00307 
00308 static void TAG(render_tri_strip_verts)( GLcontext *ctx,
00309                      GLuint start,
00310                      GLuint count,
00311                      GLuint flags )
00312 {
00313    LOCAL_VARS;
00314    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00315 
00316    if (start + 2 >= count)
00317       return;
00318 
00319    if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES ))
00320    {   
00321       int dmasz = GET_MAX_HW_ELTS();
00322       int parity = 0;
00323       GLuint j, nr;
00324 
00325       ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00326 
00327       /* Emit even number of tris in each full buffer.
00328        */
00329       dmasz = dmasz/3;
00330       dmasz -= dmasz & 1;
00331 
00332       for (j = start; j + 2 < count; j += nr - 2 ) {
00333      ELT_TYPE *dest;
00334      GLint i;
00335 
00336      nr = MIN2( dmasz, count - j );
00337      dest = ALLOC_ELTS( (nr-2)*3 );
00338         
00339      for ( i = j ; i+2 < j+nr ; i++, parity^=1 ) {
00340         EMIT_ELT( dest, 0, (i+0+parity) );
00341         EMIT_ELT( dest, 1, (i+1-parity) );
00342         EMIT_ELT( dest, 2, (i+2) );
00343         dest += 3;
00344      }
00345 
00346      CLOSE_ELTS();
00347       }
00348    }
00349    else
00350       EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count );
00351 }
00352 
00353 static void TAG(render_tri_fan_verts)( GLcontext *ctx,
00354                        GLuint start,
00355                        GLuint count,
00356                        GLuint flags )
00357 {
00358    LOCAL_VARS;
00359    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00360 
00361    if (start+2 >= count) 
00362       return;
00363 
00364    if (PREFER_DISCRETE_ELT_PRIM( count-start, HW_TRIANGLES ))
00365    {   
00366       int dmasz = GET_MAX_HW_ELTS();
00367       GLuint j, nr;
00368 
00369       ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00370 
00371       dmasz = dmasz/3;
00372 
00373       for (j = start + 1; j + 1 < count; j += nr - 1 ) {
00374      ELT_TYPE *dest;
00375      GLint i;
00376 
00377      nr = MIN2( dmasz, count - j );
00378      dest = ALLOC_ELTS( (nr-1)*3 );
00379         
00380      for ( i = j ; i+1 < j+nr ; i++ ) {
00381         EMIT_ELT( dest, 0, (start) );
00382         EMIT_ELT( dest, 1, (i) );
00383         EMIT_ELT( dest, 2, (i+1) );
00384         dest += 3;
00385      }
00386      
00387      CLOSE_ELTS();
00388       }
00389    }
00390    else {
00391       EMIT_PRIM( ctx, GL_TRIANGLE_FAN, HW_TRIANGLE_FAN, start, count );
00392    }
00393 }
00394 
00395 
00396 static void TAG(render_poly_verts)( GLcontext *ctx,
00397                     GLuint start,
00398                     GLuint count,
00399                     GLuint flags )
00400 {
00401    LOCAL_VARS;
00402    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00403 
00404    if (start+2 >= count) 
00405       return;
00406 
00407    EMIT_PRIM( ctx, GL_POLYGON, HW_POLYGON, start, count );
00408 }
00409 
00410 static void TAG(render_quad_strip_verts)( GLcontext *ctx,
00411                       GLuint start,
00412                       GLuint count,
00413                       GLuint flags )
00414 {
00415    LOCAL_VARS;
00416    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00417 
00418    count -= (count-start) & 1;
00419 
00420    if (start+3 >= count) 
00421       return;
00422 
00423    if (HAVE_QUAD_STRIPS) {
00424       EMIT_PRIM( ctx, GL_QUAD_STRIP, HW_QUAD_STRIP, start, count );
00425    } 
00426    else if (ctx->Light.ShadeModel == GL_FLAT) {
00427       LOCAL_VARS;
00428       int dmasz = GET_MAX_HW_ELTS();
00429       GLuint j, nr;
00430 
00431       ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00432 
00433       /* Emit whole number of quads in total, and in each buffer.
00434        */
00435       dmasz = (dmasz/6)*2;
00436 
00437       for (j = start; j + 3 < count; j += nr - 2 ) {
00438      ELT_TYPE *dest;
00439      GLint quads, i;
00440 
00441      nr = MIN2( dmasz, count - j );
00442      quads = (nr/2)-1;
00443      dest = ALLOC_ELTS( quads*6 );
00444         
00445      for ( i = j ; i < j+quads*2 ; i+=2 ) {
00446         EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );
00447         EMIT_TWO_ELTS( dest, 2, (i+2), (i+1) );
00448         EMIT_TWO_ELTS( dest, 4, (i+3), (i+2) );
00449         dest += 6;
00450      }
00451 
00452      CLOSE_ELTS();
00453       }
00454    }
00455    else {
00456       EMIT_PRIM( ctx, GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0, start, count );
00457    }
00458 }
00459 
00460 
00461 static void TAG(render_quads_verts)( GLcontext *ctx,
00462                      GLuint start,
00463                      GLuint count,
00464                      GLuint flags )
00465 {
00466    LOCAL_VARS;
00467    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00468    count -= (count-start)%4;
00469 
00470    if (start+3 >= count) 
00471       return;
00472 
00473    if (HAVE_QUADS) {
00474       EMIT_PRIM( ctx, GL_QUADS, HW_QUADS, start, count );
00475    } 
00476    else {
00477       /* Hardware doesn't have a quad primitive type -- simulate it
00478        * using indexed vertices and the triangle primitive: 
00479        */
00480       LOCAL_VARS;
00481       int dmasz = GET_MAX_HW_ELTS();
00482       GLuint j, nr;
00483 
00484       ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00485 
00486       /* Adjust for rendering as triangles:
00487        */
00488       dmasz = (dmasz/6)*4;
00489 
00490       for (j = start; j < count; j += nr ) {
00491      ELT_TYPE *dest;
00492      GLint quads, i;
00493 
00494      nr = MIN2( dmasz, count - j );
00495      quads = nr/4;
00496      dest = ALLOC_ELTS( quads*6 );
00497 
00498      for ( i = j ; i < j+quads*4 ; i+=4 ) {
00499         EMIT_TWO_ELTS( dest, 0, (i+0), (i+1) );
00500         EMIT_TWO_ELTS( dest, 2, (i+3), (i+1) );
00501         EMIT_TWO_ELTS( dest, 4, (i+2), (i+3) );
00502         dest += 6;
00503      }
00504 
00505      CLOSE_ELTS();
00506       }
00507    }
00508 }
00509 
00510 static void TAG(render_noop)( GLcontext *ctx,
00511                   GLuint start,
00512                   GLuint count,
00513                   GLuint flags )
00514 {
00515 }
00516 
00517 
00518 
00519 
00520 static tnl_render_func TAG(render_tab_verts)[GL_POLYGON+2] =
00521 {
00522    TAG(render_points_verts),
00523    TAG(render_lines_verts),
00524    TAG(render_line_loop_verts),
00525    TAG(render_line_strip_verts),
00526    TAG(render_triangles_verts),
00527    TAG(render_tri_strip_verts),
00528    TAG(render_tri_fan_verts),
00529    TAG(render_quads_verts),
00530    TAG(render_quad_strip_verts),
00531    TAG(render_poly_verts),
00532    TAG(render_noop),
00533 };
00534 
00535 
00536 /****************************************************************************
00537  *                 Render elts using hardware indexed verts                 *
00538  ****************************************************************************/
00539 
00540 static void TAG(render_points_elts)( GLcontext *ctx,
00541                      GLuint start,
00542                      GLuint count,
00543                      GLuint flags )
00544 {
00545    LOCAL_VARS;
00546    int dmasz = GET_MAX_HW_ELTS();
00547    GLuint *elts = GET_MESA_ELTS();
00548    GLuint j, nr;
00549    ELT_TYPE *dest;
00550 
00551    ELT_INIT( GL_POINTS, HW_POINTS );
00552 
00553    for (j = start; j < count; j += nr ) {
00554       nr = MIN2( dmasz, count - j );
00555       dest = ALLOC_ELTS( nr );
00556       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00557       CLOSE_ELTS();
00558    }
00559 }
00560 
00561 
00562 
00563 static void TAG(render_lines_elts)( GLcontext *ctx,
00564                     GLuint start,
00565                     GLuint count,
00566                     GLuint flags )
00567 {
00568    LOCAL_VARS;
00569    int dmasz = GET_MAX_HW_ELTS();
00570    GLuint *elts = GET_MESA_ELTS();
00571    GLuint j, nr;
00572    ELT_TYPE *dest;
00573 
00574    if (start+1 >= count)
00575       return;
00576 
00577    if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag) {
00578       RESET_STIPPLE();
00579       AUTO_STIPPLE( GL_TRUE );
00580    }
00581 
00582    ELT_INIT( GL_LINES, HW_LINES );
00583 
00584    /* Emit whole number of lines in total and in each buffer:
00585     */
00586    count -= (count-start) & 1;
00587    dmasz -= dmasz & 1;
00588 
00589    for (j = start; j < count; j += nr ) {
00590       nr = MIN2( dmasz, count - j );
00591       dest = ALLOC_ELTS( nr );
00592       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00593       CLOSE_ELTS();
00594    }
00595 
00596    if ((flags & PRIM_END) && ctx->Line.StippleFlag)
00597       AUTO_STIPPLE( GL_FALSE );
00598 }
00599 
00600 
00601 static void TAG(render_line_strip_elts)( GLcontext *ctx,
00602                      GLuint start,
00603                      GLuint count,
00604                      GLuint flags )
00605 {
00606    LOCAL_VARS;
00607    int dmasz = GET_MAX_HW_ELTS();
00608    GLuint *elts = GET_MESA_ELTS();
00609    GLuint j, nr;
00610    ELT_TYPE *dest;
00611 
00612    if (start+1 >= count)
00613       return;
00614 
00615    ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );
00616 
00617    if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)
00618       RESET_STIPPLE();
00619 
00620    for (j = start; j + 1 < count; j += nr - 1 ) {
00621       nr = MIN2( dmasz, count - j );
00622       dest = ALLOC_ELTS( nr );
00623       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00624       CLOSE_ELTS();
00625    }
00626 }
00627 
00628 
00629 static void TAG(render_line_loop_elts)( GLcontext *ctx,
00630                     GLuint start,
00631                     GLuint count,
00632                     GLuint flags )
00633 {
00634    LOCAL_VARS;
00635    int dmasz = GET_MAX_HW_ELTS();
00636    GLuint *elts = GET_MESA_ELTS();
00637    GLuint j, nr;
00638    ELT_TYPE *dest;
00639 
00640    if (0) fprintf(stderr, "%s\n", __FUNCTION__);
00641 
00642    if (flags & PRIM_BEGIN)
00643       j = start;
00644    else
00645       j = start + 1;
00646 
00647    
00648    if (flags & PRIM_END) {
00649       if (start+1 >= count)
00650      return;
00651    } 
00652    else {
00653       if (j+1 >= count)
00654      return;
00655    }
00656 
00657    ELT_INIT( GL_LINE_STRIP, HW_LINE_STRIP );
00658 
00659    if ((flags & PRIM_BEGIN) && ctx->Line.StippleFlag)
00660       RESET_STIPPLE();
00661 
00662    
00663    /* Ensure last vertex doesn't wrap:
00664     */
00665    dmasz--;
00666 
00667    for ( ; j + 1 < count; ) {
00668       nr = MIN2( dmasz, count - j );
00669       dest = ALLOC_ELTS( nr+1 );    /* Reserve possible space for last elt */
00670       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00671       j += nr - 1;
00672       if (j + 1 >= count && (flags & PRIM_END)) {
00673      dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
00674       }
00675       CLOSE_ELTS();
00676    }
00677 }
00678 
00679 
00680 static void TAG(render_triangles_elts)( GLcontext *ctx,
00681                     GLuint start,
00682                     GLuint count,
00683                     GLuint flags )
00684 {
00685    LOCAL_VARS;
00686    GLuint *elts = GET_MESA_ELTS();
00687    int dmasz = GET_MAX_HW_ELTS()/3*3;
00688    GLuint j, nr;
00689    ELT_TYPE *dest;
00690 
00691    if (start+2 >= count)
00692       return;
00693 
00694    ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00695 
00696 
00697    /* Emit whole number of tris in total.  dmasz is already a multiple
00698     * of 3.
00699     */
00700    count -= (count-start)%3;
00701 
00702    for (j = start; j < count; j += nr) {
00703       nr = MIN2( dmasz, count - j );
00704       dest = ALLOC_ELTS( nr );
00705       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00706       CLOSE_ELTS();
00707    }
00708 }
00709 
00710 
00711 
00712 static void TAG(render_tri_strip_elts)( GLcontext *ctx,
00713                     GLuint start,
00714                     GLuint count,
00715                     GLuint flags )
00716 {
00717    LOCAL_VARS;
00718    GLuint j, nr;
00719    GLuint *elts = GET_MESA_ELTS();
00720    int dmasz = GET_MAX_HW_ELTS();
00721    ELT_TYPE *dest;
00722 
00723    if (start+2 >= count)
00724       return;
00725 
00726    ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 );
00727 
00728    /* Keep the same winding over multiple buffers:
00729     */
00730    dmasz -= (dmasz & 1);
00731 
00732    for (j = start ; j + 2 < count; j += nr - 2 ) {
00733       nr = MIN2( dmasz, count - j );
00734 
00735       dest = ALLOC_ELTS( nr );
00736       dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00737       CLOSE_ELTS();
00738    }
00739 }
00740 
00741 static void TAG(render_tri_fan_elts)( GLcontext *ctx,
00742                       GLuint start,
00743                       GLuint count,
00744                       GLuint flags )
00745 {
00746    LOCAL_VARS;
00747    GLuint *elts = GET_MESA_ELTS();
00748    GLuint j, nr;
00749    int dmasz = GET_MAX_HW_ELTS();
00750    ELT_TYPE *dest;
00751 
00752    if (start+2 >= count)
00753       return;
00754 
00755    ELT_INIT( GL_TRIANGLE_FAN, HW_TRIANGLE_FAN );
00756 
00757    for (j = start + 1 ; j + 1 < count; j += nr - 1 ) {
00758       nr = MIN2( dmasz, count - j + 1 );
00759       dest = ALLOC_ELTS( nr );
00760       dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
00761       dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
00762       CLOSE_ELTS();
00763    }
00764 }
00765 
00766 
00767 static void TAG(render_poly_elts)( GLcontext *ctx,
00768                    GLuint start,
00769                    GLuint count,
00770                    GLuint flags )
00771 {
00772    LOCAL_VARS;
00773    GLuint *elts = GET_MESA_ELTS();
00774    GLuint j, nr;
00775    int dmasz = GET_MAX_HW_ELTS();
00776    ELT_TYPE *dest;
00777 
00778    if (start+2 >= count)
00779       return;
00780 
00781    ELT_INIT( GL_POLYGON, HW_POLYGON );
00782 
00783    for (j = start + 1 ; j + 1 < count ; j += nr - 1 ) {
00784       nr = MIN2( dmasz, count - j + 1 );
00785       dest = ALLOC_ELTS( nr );
00786       dest = TAG(emit_elts)( ctx, dest, elts+start, 1 );
00787       dest = TAG(emit_elts)( ctx, dest, elts+j, nr - 1 );
00788       CLOSE_ELTS();
00789    }
00790 }
00791 
00792 static void TAG(render_quad_strip_elts)( GLcontext *ctx,
00793                      GLuint start,
00794                      GLuint count,
00795                      GLuint flags )
00796 {
00797    if (start+3 >= count)
00798       return;
00799 
00800    if (HAVE_QUAD_STRIPS && 0) {
00801    }
00802    else {
00803       LOCAL_VARS;
00804       GLuint *elts = GET_MESA_ELTS();
00805       int dmasz = GET_MAX_HW_ELTS();
00806       GLuint j, nr;
00807       ELT_TYPE *dest;
00808 
00809       /* Emit whole number of quads in total, and in each buffer.
00810        */
00811       dmasz -= dmasz & 1;
00812       count -= (count-start) & 1;
00813 
00814       if (ctx->Light.ShadeModel == GL_FLAT) {
00815      ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00816 
00817      dmasz = dmasz/6*2;
00818 
00819      for (j = start; j + 3 < count; j += nr - 2 ) {
00820         nr = MIN2( dmasz, count - j );
00821 
00822         if (nr >= 4)
00823         {
00824            GLint quads = (nr/2)-1;
00825            ELT_TYPE *dest = ALLOC_ELTS( quads*6 );
00826            GLint i;
00827 
00828            for ( i = j-start ; i < j-start+quads ; i++, elts += 2 ) {
00829           EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );
00830           EMIT_TWO_ELTS( dest, 2, elts[2], elts[1] );
00831           EMIT_TWO_ELTS( dest, 4, elts[3], elts[2] );
00832           dest += 6;
00833            }
00834 
00835            CLOSE_ELTS();
00836         }
00837      }
00838       }
00839       else {
00840      ELT_INIT( GL_TRIANGLE_STRIP, HW_TRIANGLE_STRIP_0 );
00841 
00842      for (j = start; j + 3 < count; j += nr - 2 ) {
00843         nr = MIN2( dmasz, count - j );
00844         dest = ALLOC_ELTS( nr );
00845         dest = TAG(emit_elts)( ctx, dest, elts+j, nr );
00846         CLOSE_ELTS();
00847      }
00848       }
00849    }
00850 }
00851 
00852 
00853 static void TAG(render_quads_elts)( GLcontext *ctx,
00854                     GLuint start,
00855                     GLuint count,
00856                     GLuint flags )
00857 {
00858    if (start+3 >= count)
00859       return;
00860 
00861    if (HAVE_QUADS && 0) {
00862    } else {
00863       LOCAL_VARS;
00864       GLuint *elts = GET_MESA_ELTS();
00865       int dmasz = GET_MAX_HW_ELTS();
00866       GLuint j, nr;
00867 
00868       ELT_INIT( GL_TRIANGLES, HW_TRIANGLES );
00869 
00870       /* Emit whole number of quads in total, and in each buffer.
00871        */
00872       dmasz -= dmasz & 3;
00873       count -= (count-start) & 3;
00874 
00875       /* Adjust for rendering as triangles:
00876        */
00877       dmasz = dmasz/6*4;
00878 
00879       for (j = start; j + 3 < count; j += nr ) {
00880      nr = MIN2( dmasz, count - j );
00881 
00882      {
00883         GLint quads = nr/4;
00884         ELT_TYPE *dest = ALLOC_ELTS( quads * 6 );
00885         GLint i;
00886 
00887         for ( i = j-start ; i < j-start+quads ; i++, elts += 4 ) {
00888            EMIT_TWO_ELTS( dest, 0, elts[0], elts[1] );
00889            EMIT_TWO_ELTS( dest, 2, elts[3], elts[1] );
00890            EMIT_TWO_ELTS( dest, 4, elts[2], elts[3] );
00891            dest += 6;
00892         }
00893 
00894         CLOSE_ELTS();
00895      }
00896       }
00897    }
00898 }
00899 
00900 
00901 
00902 static tnl_render_func TAG(render_tab_elts)[GL_POLYGON+2] =
00903 {
00904    TAG(render_points_elts),
00905    TAG(render_lines_elts),
00906    TAG(render_line_loop_elts),
00907    TAG(render_line_strip_elts),
00908    TAG(render_triangles_elts),
00909    TAG(render_tri_strip_elts),
00910    TAG(render_tri_fan_elts),
00911    TAG(render_quads_elts),
00912    TAG(render_quad_strip_elts),
00913    TAG(render_poly_elts),
00914    TAG(render_noop),
00915 };

Generated on Sat May 26 2012 04:19:37 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.