Ignore:
Timestamp:
May 23, 2000, 10:41:28 PM (25 years ago)
Author:
jeroen
Message:

* empty log message *

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/opengl/mesa/varray.c

    r2962 r3598  
    1 /* $Id: varray.c,v 1.2 2000-03-01 18:49:38 jeroen Exp $ */
     1/* $Id: varray.c,v 1.3 2000-05-23 20:40:59 jeroen Exp $ */
    22
    33/*
     
    2828#include "all.h"
    2929#else
    30 #ifndef XFree86Server
    31 #include <stdlib.h>
    32 #include <stdio.h>
    33 #include <string.h>
    34 #else
    35 #include "GL/xf86glx.h"
    36 #endif
     30#include "glheader.h"
    3731#include "types.h"
    3832#include "context.h"
    39 #include "api.h"
    4033#include "cva.h"
    4134#include "enable.h"
     
    5548#include "vbxform.h"
    5649#include "xform.h"
    57 #ifdef XFree86Server
    58 #include "GL/xf86glx.h"
     50#include "state.h"
    5951#endif
    60 #endif
    61 
    62 #if defined(GLX_DIRECT_RENDERING) && !defined(XFree86Server) && !defined(GLX_USE_DLOPEN)
    63 #define NEED_MESA_FUNCS_WRAPPED
    64 #include "mesa_api.h"
    65 #endif
    66 
    67 
    68 void GLAPIENTRY glVertexPointer(CTX_ARG GLint size, GLenum type, GLsizei stride,
    69                                  const GLvoid *ptr )
    70 {
    71    GLcontext *ctx;
    72    GET_CONTEXT;
    73    CHECK_CONTEXT;
    74    ctx = CC;
     52
     53void
     54_mesa_VertexPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr )
     55{
     56   GET_CURRENT_CONTEXT(ctx);
    7557
    7658   if (size<2 || size>4) {
     
    8567   if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
    8668      fprintf(stderr, "glVertexPointer( sz %d type %s stride %d )\n", size,
    87               gl_lookup_enum_by_nr( type ),
    88               stride);
     69              gl_lookup_enum_by_nr( type ),
     70              stride);
    8971
    9072   ctx->Array.Vertex.StrideB = stride;
     
    121103
    122104
    123 void GLAPIENTRY glNormalPointer(CTX_ARG GLenum type, GLsizei stride,
    124                                  const GLvoid *ptr )
    125 {
    126    GLcontext *ctx;
    127    GET_CONTEXT;
    128    CHECK_CONTEXT;
    129    ctx = CC;
     105void
     106_mesa_NormalPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
     107{
     108   GET_CURRENT_CONTEXT(ctx);
    130109
    131110   if (stride<0) {
     
    136115   if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
    137116      fprintf(stderr, "glNormalPointer( type %s stride %d )\n",
    138               gl_lookup_enum_by_nr( type ),
    139               stride);
     117              gl_lookup_enum_by_nr( type ),
     118              stride);
    140119
    141120   ctx->Array.Normal.StrideB = stride;
     
    173152
    174153
    175 void GLAPIENTRY glColorPointer(CTX_ARG GLint size, GLenum type, GLsizei stride,
    176                                 const GLvoid *ptr )
    177 {
    178    GLcontext *ctx;
    179    GET_CONTEXT;
    180    CHECK_CONTEXT;
    181    ctx = CC;
     154void
     155_mesa_ColorPointer(GLint size, GLenum type, GLsizei stride,const GLvoid *ptr )
     156{
     157   GET_CURRENT_CONTEXT(ctx);
     158
    182159   if (size<3 || size>4) {
    183160      gl_error( ctx, GL_INVALID_VALUE, "glColorPointer(size)" );
     
    191168   if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
    192169      fprintf(stderr, "glColorPointer( sz %d type %s stride %d )\n", size,
    193           gl_lookup_enum_by_nr( type ),
    194           stride);
     170          gl_lookup_enum_by_nr( type ),
     171          stride);
    195172
    196173   ctx->Array.Color.StrideB = stride;
     
    238215
    239216
    240 void GLAPIENTRY glIndexPointer(CTX_ARG GLenum type, GLsizei stride,
    241                                 const GLvoid *ptr )
    242 {
    243    GLcontext *ctx;
    244    GET_CONTEXT;
    245    CHECK_CONTEXT;
    246    ctx = CC;
     217void
     218_mesa_IndexPointer(GLenum type, GLsizei stride, const GLvoid *ptr )
     219{
     220   GET_CURRENT_CONTEXT(ctx);
    247221
    248222   if (stride<0) {
     
    285259
    286260
    287 void GLAPIENTRY glTexCoordPointer(CTX_ARG GLint size, GLenum type,
    288                                    GLsizei stride, const GLvoid *ptr )
    289 {
     261void
     262_mesa_TexCoordPointer(GLint size, GLenum type, GLsizei stride, const GLvoid *ptr )
     263{
     264   GET_CURRENT_CONTEXT(ctx);
    290265   GLuint texUnit;
    291 
    292    GLcontext *ctx;
    293    GET_CONTEXT;
    294    CHECK_CONTEXT;
    295    ctx = CC;
    296266
    297267   texUnit = ctx->Array.ActiveTexture;
     
    308278   if (MESA_VERBOSE&(VERBOSE_VARRAY|VERBOSE_API))
    309279      fprintf(stderr, "glTexCoordPointer( unit %u sz %d type %s stride %d )\n",
    310           texUnit,
    311           size,
    312           gl_lookup_enum_by_nr( type ),
    313           stride);
     280          texUnit,
     281          size,
     282          gl_lookup_enum_by_nr( type ),
     283          stride);
    314284
    315285   ctx->Array.TexCoord[texUnit].StrideB = stride;
     
    347317
    348318
    349 void GLAPIENTRY glEdgeFlagPointer(CTX_ARG GLsizei stride, const void *vptr )
    350 {
     319void
     320_mesa_EdgeFlagPointer(GLsizei stride, const void *vptr )
     321{
     322   GET_CURRENT_CONTEXT(ctx);
    351323   const GLboolean *ptr = (GLboolean *)vptr;
    352 
    353    GLcontext *ctx;
    354    GET_CONTEXT;
    355    CHECK_CONTEXT;
    356    ctx = CC;
    357324
    358325   if (stride<0) {
     
    373340}
    374341
    375 
     342#if 0
    376343/* Called only from gl_DrawElements
    377344 */
    378 void gl_CVAEltPointer( GLcontext *ctx, GLenum type, const GLvoid *ptr )
     345static void gl_CVAEltPointer( GLcontext *ctx, GLenum type, const GLvoid *ptr )
    379346{
    380347   switch (type) {
     
    396363   ctx->CVA.Elt.Ptr = (void *) ptr;
    397364   ctx->CVA.EltFunc = gl_trans_1ui_tab[TYPE_IDX(type)];
    398    ctx->Array.NewArrayState |= VERT_ELT; /* ??? */
    399 }
    400 
     365   ctx->Array.NewArrayState |= VERT_ELT;                             /* ???*/
     366}
     367#endif
    401368
    402369
     
    409376 */
    410377void gl_exec_array_elements( GLcontext *ctx, struct immediate *IM,
    411                              GLuint start,
    412                              GLuint count)
     378                             GLuint start,
     379                             GLuint count)
    413380{
    414381   GLuint *flags = IM->Flag;
     
    422389   if (translate & VERT_OBJ_ANY)
    423390      (ctx->Array.VertexEltFunc)( IM->Obj,
    424                                   &ctx->Array.Vertex,
    425                                   flags, elts, (VERT_ELT|VERT_OBJ_ANY),
    426                                   start, count);
     391                                  &ctx->Array.Vertex,
     392                                  flags, elts, (VERT_ELT|VERT_OBJ_ANY),
     393                                  start, count);
    427394
    428395   if (translate & VERT_NORM)
    429396      (ctx->Array.NormalEltFunc)( IM->Normal,
    430                                   &ctx->Array.Normal,
    431                                   flags, elts, (VERT_ELT|VERT_NORM),
    432                                   start, count);
     397                                  &ctx->Array.Normal,
     398                                  flags, elts, (VERT_ELT|VERT_NORM),
     399                                  start, count);
    433400
    434401   if (translate & VERT_EDGE)
    435402      (ctx->Array.EdgeFlagEltFunc)( IM->EdgeFlag,
    436                                     &ctx->Array.EdgeFlag,
    437                                     flags, elts, (VERT_ELT|VERT_EDGE),
    438                                     start, count);
     403                                    &ctx->Array.EdgeFlag,
     404                                    flags, elts, (VERT_ELT|VERT_EDGE),
     405                                    start, count);
    439406
    440407   if (translate & VERT_RGBA)
    441408      (ctx->Array.ColorEltFunc)( IM->Color,
    442                                 &ctx->Array.Color,
    443                                 flags, elts, (VERT_ELT|VERT_RGBA),
    444                                 start, count);
     409                                &ctx->Array.Color,
     410                                flags, elts, (VERT_ELT|VERT_RGBA),
     411                                start, count);
    445412
    446413   if (translate & VERT_INDEX)
    447414      (ctx->Array.IndexEltFunc)( IM->Index,
    448                                 &ctx->Array.Index,
    449                                 flags, elts, (VERT_ELT|VERT_INDEX),
    450                                 start, count);
     415                                &ctx->Array.Index,
     416                                flags, elts, (VERT_ELT|VERT_INDEX),
     417                                start, count);
    451418
    452419   if (translate & VERT_TEX0_ANY)
    453420      (ctx->Array.TexCoordEltFunc[0])( IM->TexCoord[0],
    454                                        &ctx->Array.TexCoord[0],
    455                                        flags, elts, (VERT_ELT|VERT_TEX0_ANY),
    456                                        start, count);
     421                                       &ctx->Array.TexCoord[0],
     422                                       flags, elts, (VERT_ELT|VERT_TEX0_ANY),
     423                                       start, count);
    457424
    458425   if (translate & VERT_TEX1_ANY)
    459426      (ctx->Array.TexCoordEltFunc[1])( IM->TexCoord[1],
    460                                        &ctx->Array.TexCoord[1],
    461                                        flags, elts, (VERT_ELT|VERT_TEX1_ANY),
    462                                        start, count);
     427                                       &ctx->Array.TexCoord[1],
     428                                       flags, elts, (VERT_ELT|VERT_TEX1_ANY),
     429                                       start, count);
    463430
    464431
    465432   for (i = start ; i < count ; i++)
    466433      if (flags[i] & VERT_ELT)
    467          flags[i] |= translate;
    468 
    469 }
    470 
    471 
    472 
    473 void gl_DrawArrays( GLcontext *ctx, GLenum mode, GLint start, GLsizei count )
    474 {
     434         flags[i] |= translate;
     435
     436}
     437
     438
     439
     440/* Enough funny business going on in here it might be quicker to use a
     441 * function pointer.
     442 */
     443#define ARRAY_ELT( IM, i )                                      \
     444{                                                               \
     445   GLuint count = IM->Count;                                    \
     446   IM->Elt[count] = i;                                          \
     447   IM->Flag[count] = ((IM->Flag[count] & IM->ArrayAndFlags) |   \
     448                      VERT_ELT);                                \
     449   IM->FlushElt |= IM->ArrayEltFlush;                           \
     450   IM->Count = count += IM->ArrayIncr;                          \
     451   if (count == VB_MAX)                                         \
     452      IM->maybe_transform_vb( IM );                             \
     453}
     454
     455
     456void
     457_mesa_ArrayElement( GLint i )
     458{
     459   GET_IMMEDIATE;
     460   ARRAY_ELT( IM, i );
     461}
     462
     463
     464static void
     465gl_ArrayElement( GLcontext *CC, GLint i )
     466{
     467   struct immediate *im = CC->input;
     468   ARRAY_ELT( im, i );
     469}
     470
     471
     472
     473void
     474_mesa_DrawArrays(GLenum mode, GLint start, GLsizei count)
     475{
     476   GET_CURRENT_CONTEXT(ctx);
    475477   struct vertex_buffer *VB = ctx->VB;
    476478   GLint i;
     
    498500
    499501      if (ctx->NewState)
    500          gl_update_state( ctx );       
     502         gl_update_state( ctx );
    501503
    502504      /* Just turn off cva on this path.  Could be useful for multipass
     
    506508
    507509      if (relock) {
    508         ctx->CompileCVAFlag = 0;
    509         elt->pipeline_valid = 0;
     510        ctx->CompileCVAFlag = 0;
     511        elt->pipeline_valid = 0;
    510512      }
    511513
    512514      if (!elt->pipeline_valid)
    513         gl_build_immediate_pipeline( ctx );
     515        gl_build_immediate_pipeline( ctx );
    514516
    515517      required = elt->inputs;
     
    523525      if (required & VERT_RGBA)
    524526      {
    525         Color = &ctx->Array.Color;
    526         if (fallback & VERT_RGBA) {
    527             Color = &ctx->Fallback.Color;
    528             ctx->Array.ColorFunc =
    529                gl_trans_4ub_tab[4][TYPE_IDX(GL_UNSIGNED_BYTE)];
    530         }
     527        Color = &ctx->Array.Color;
     528        if (fallback & VERT_RGBA) {
     529            Color = &ctx->Fallback.Color;
     530            ctx->Array.ColorFunc =
     531               gl_trans_4ub_tab[4][TYPE_IDX(GL_UNSIGNED_BYTE)];
     532        }
    531533      }
    532534
    533535      if (required & VERT_INDEX)
    534536      {
    535         Index = &ctx->Array.Index;
    536         if (fallback & VERT_INDEX) {
    537             Index = &ctx->Fallback.Index;
    538             ctx->Array.IndexFunc = gl_trans_1ui_tab[TYPE_IDX(GL_UNSIGNED_INT)];
    539         }
     537        Index = &ctx->Array.Index;
     538        if (fallback & VERT_INDEX) {
     539            Index = &ctx->Fallback.Index;
     540            ctx->Array.IndexFunc = gl_trans_1ui_tab[TYPE_IDX(GL_UNSIGNED_INT)];
     541        }
    540542      }
    541543
    542544      for (i = 0 ; i < MAX_TEXTURE_UNITS ; i++)
    543545      {
    544         GLuint flag = VERT_TEX_ANY(i);
    545 
    546         if (required & flag) {
    547             TexCoord[i] = &ctx->Array.TexCoord[i];
    548 
    549             if (fallback & flag)
    550             {
    551                TexCoord[i] = &ctx->Fallback.TexCoord[i];
    552                TexCoord[i]->Size = gl_texcoord_size( ctx->Current.Flag, i );
    553 
    554                ctx->Array.TexCoordFunc[i] =
    555                   gl_trans_4f_tab[TexCoord[i]->Size][TYPE_IDX(GL_FLOAT)];
    556             }
    557         }
     546        GLuint flag = VERT_TEX_ANY(i);
     547
     548        if (required & flag) {
     549            TexCoord[i] = &ctx->Array.TexCoord[i];
     550
     551            if (fallback & flag)
     552            {
     553               TexCoord[i] = &ctx->Fallback.TexCoord[i];
     554               TexCoord[i]->Size = gl_texcoord_size( ctx->Current.Flag, i );
     555
     556               ctx->Array.TexCoordFunc[i] =
     557                  gl_trans_4f_tab[TexCoord[i]->Size][TYPE_IDX(GL_FLOAT)];
     558            }
     559        }
    558560      }
    559561
    560562      if (ctx->Array.Flags != ctx->Array.Flag[0])
    561          for (i = 0 ; i < VB_MAX ; i++)
    562             ctx->Array.Flag[i] = ctx->Array.Flags;
     563         for (i = 0 ; i < VB_MAX ; i++)
     564            ctx->Array.Flag[i] = ctx->Array.Flags;
    563565
    564566
    565567      if (required & VERT_NORM)
    566568      {
    567         Normal = &ctx->Array.Normal;
    568         if (fallback & VERT_NORM) {
    569             Normal = &ctx->Fallback.Normal;
    570             ctx->Array.NormalFunc = gl_trans_3f_tab[TYPE_IDX(GL_FLOAT)];
    571         }
     569        Normal = &ctx->Array.Normal;
     570        if (fallback & VERT_NORM) {
     571            Normal = &ctx->Fallback.Normal;
     572            ctx->Array.NormalFunc = gl_trans_3f_tab[TYPE_IDX(GL_FLOAT)];
     573        }
    572574      }
    573575
    574576      if ( required & VERT_EDGE )
    575577      {
    576         if (mode == GL_TRIANGLES ||
    577              mode == GL_QUADS ||
    578              mode == GL_POLYGON)
    579         {
    580             EdgeFlag = &ctx->Array.EdgeFlag;
    581             if (fallback & VERT_EDGE) {
    582                EdgeFlag = &ctx->Fallback.EdgeFlag;
    583                ctx->Array.EdgeFlagFunc =
    584                   gl_trans_1ub_tab[TYPE_IDX(GL_UNSIGNED_BYTE)];
    585             }
    586         }
    587         else
    588             required &= ~VERT_EDGE;
     578        if (mode == GL_TRIANGLES ||
     579             mode == GL_QUADS ||
     580             mode == GL_POLYGON)
     581        {
     582            EdgeFlag = &ctx->Array.EdgeFlag;
     583            if (fallback & VERT_EDGE) {
     584               EdgeFlag = &ctx->Fallback.EdgeFlag;
     585               ctx->Array.EdgeFlagFunc =
     586                  gl_trans_1ub_tab[TYPE_IDX(GL_UNSIGNED_BYTE)];
     587            }
     588        }
     589        else
     590            required &= ~VERT_EDGE;
    589591      }
    590592
     
    597599      while (remaining > 0) {
    598600         GLint vbspace = VB_MAX - VB_START;
    599         GLuint count, n;
    600        
    601         if (vbspace >= remaining) {
    602             n = remaining;
    603             VB->LastPrimitive = VB_START + n;
    604         } else {
    605             n = vbspace;
    606             VB->LastPrimitive = VB_START;
    607         }
    608        
    609         VB->CullMode = 0;
    610        
    611         ctx->Array.VertexFunc( IM->Obj + VB_START,
    612                                 &ctx->Array.Vertex, start, n );
    613        
    614         if (required & VERT_NORM) {
    615             ctx->Array.NormalFunc( IM->Normal + VB_START,
    616                                    Normal, start, n );
    617         }
    618        
    619         if (required & VERT_EDGE) {
    620             ctx->Array.EdgeFlagFunc( IM->EdgeFlag + VB_START,
    621                                      EdgeFlag, start, n );
    622         }
    623        
    624         if (required & VERT_RGBA) {
    625             ctx->Array.ColorFunc( IM->Color + VB_START,
    626                                   Color, start, n );
    627         }
    628        
    629         if (required & VERT_INDEX) {
    630             ctx->Array.IndexFunc( IM->Index + VB_START,
    631                                   Index, start, n );
    632         }
    633        
    634         if (required & VERT_TEX0_ANY) {
    635             IM->v.TexCoord[0].size = TexCoord[0]->Size;
    636             ctx->Array.TexCoordFunc[0]( IM->TexCoord[0] + VB_START,
    637                                         TexCoord[0], start, n );
    638         }
    639        
    640         if (required & VERT_TEX1_ANY) {
    641             IM->v.TexCoord[1].size = TexCoord[1]->Size;
    642             ctx->Array.TexCoordFunc[1]( IM->TexCoord[1] + VB_START,
    643                                         TexCoord[1], start, n );
    644         }
    645 
    646         VB->ObjPtr = &IM->v.Obj;
    647         VB->NormalPtr = &IM->v.Normal;
    648         VB->ColorPtr = &IM->v.Color;
    649         VB->Color[0] = VB->Color[1] = VB->ColorPtr;
    650         VB->IndexPtr = &IM->v.Index;
    651         VB->EdgeFlagPtr = &IM->v.EdgeFlag;
    652         VB->TexCoordPtr[0] = &IM->v.TexCoord[0];
    653         VB->TexCoordPtr[1] = &IM->v.TexCoord[1];
    654 
    655         VB->Flag = ctx->Array.Flag;
    656         VB->OrFlag = ctx->Array.Flags;
    657 
    658         VB->Start = IM->Start = VB_START;
    659         count = VB->Count = IM->Count = VB_START + n;
     601        GLuint count, n;
     602
     603        if (vbspace >= remaining) {
     604            n = remaining;
     605            VB->LastPrimitive = VB_START + n;
     606        } else {
     607            n = vbspace;
     608            VB->LastPrimitive = VB_START;
     609        }
     610
     611        VB->CullMode = 0;
     612
     613        ctx->Array.VertexFunc( IM->Obj + VB_START,
     614                                &ctx->Array.Vertex, start, n );
     615
     616        if (required & VERT_NORM) {
     617            ctx->Array.NormalFunc( IM->Normal + VB_START,
     618                                   Normal, start, n );
     619        }
     620
     621        if (required & VERT_EDGE) {
     622            ctx->Array.EdgeFlagFunc( IM->EdgeFlag + VB_START,
     623                                     EdgeFlag, start, n );
     624        }
     625
     626        if (required & VERT_RGBA) {
     627            ctx->Array.ColorFunc( IM->Color + VB_START,
     628                                  Color, start, n );
     629        }
     630
     631        if (required & VERT_INDEX) {
     632            ctx->Array.IndexFunc( IM->Index + VB_START,
     633                                  Index, start, n );
     634        }
     635
     636        if (required & VERT_TEX0_ANY) {
     637            IM->v.TexCoord[0].size = TexCoord[0]->Size;
     638            ctx->Array.TexCoordFunc[0]( IM->TexCoord[0] + VB_START,
     639                                        TexCoord[0], start, n );
     640        }
     641
     642        if (required & VERT_TEX1_ANY) {
     643            IM->v.TexCoord[1].size = TexCoord[1]->Size;
     644            ctx->Array.TexCoordFunc[1]( IM->TexCoord[1] + VB_START,
     645                                        TexCoord[1], start, n );
     646        }
     647
     648        VB->ObjPtr = &IM->v.Obj;
     649        VB->NormalPtr = &IM->v.Normal;
     650        VB->ColorPtr = &IM->v.Color;
     651        VB->Color[0] = VB->Color[1] = VB->ColorPtr;
     652        VB->IndexPtr = &IM->v.Index;
     653        VB->EdgeFlagPtr = &IM->v.EdgeFlag;
     654        VB->TexCoordPtr[0] = &IM->v.TexCoord[0];
     655        VB->TexCoordPtr[1] = &IM->v.TexCoord[1];
     656
     657        VB->Flag = ctx->Array.Flag;
     658        VB->OrFlag = ctx->Array.Flags;
     659
     660        VB->Start = IM->Start = VB_START;
     661        count = VB->Count = IM->Count = VB_START + n;
    660662
    661663#define RESET_VEC(v, t, s, c) (v.start = t v.data[s], v.count = c)
    662664
    663         RESET_VEC(IM->v.Obj, (GLfloat *), VB_START, count);
    664         RESET_VEC(IM->v.Normal, (GLfloat *), VB_START, count);
    665         RESET_VEC(IM->v.TexCoord[0], (GLfloat *), VB_START, count);
    666         RESET_VEC(IM->v.TexCoord[1], (GLfloat *), VB_START, count);
    667         RESET_VEC(IM->v.Index, &, VB_START, count);
    668         RESET_VEC(IM->v.Elt, &, VB_START, count);
    669         RESET_VEC(IM->v.EdgeFlag, &, VB_START, count);
    670         RESET_VEC(IM->v.Color, (GLubyte *), VB_START, count);
    671         RESET_VEC(VB->Clip, (GLfloat *), VB_START, count);
    672         RESET_VEC(VB->Eye, (GLfloat *), VB_START, count);
    673         RESET_VEC(VB->Win, (GLfloat *), VB_START, count);
    674         RESET_VEC(VB->BColor, (GLubyte *), VB_START, count);
    675         RESET_VEC(VB->BIndex, &, VB_START, count);
    676 
    677         VB->NextPrimitive[VB->CopyStart] = VB->Count;
    678         VB->Primitive[VB->CopyStart] = mode;
    679         ctx->Array.Flag[count] |= VERT_END_VB;
     665        RESET_VEC(IM->v.Obj, (GLfloat *), VB_START, count);
     666        RESET_VEC(IM->v.Normal, (GLfloat *), VB_START, count);
     667        RESET_VEC(IM->v.TexCoord[0], (GLfloat *), VB_START, count);
     668        RESET_VEC(IM->v.TexCoord[1], (GLfloat *), VB_START, count);
     669        RESET_VEC(IM->v.Index, &, VB_START, count);
     670        RESET_VEC(IM->v.Elt, &, VB_START, count);
     671        RESET_VEC(IM->v.EdgeFlag, &, VB_START, count);
     672        RESET_VEC(IM->v.Color, (GLubyte *), VB_START, count);
     673        RESET_VEC(VB->Clip, (GLfloat *), VB_START, count);
     674        RESET_VEC(VB->Eye, (GLfloat *), VB_START, count);
     675        RESET_VEC(VB->Win, (GLfloat *), VB_START, count);
     676        RESET_VEC(VB->BColor, (GLubyte *), VB_START, count);
     677        RESET_VEC(VB->BIndex, &, VB_START, count);
     678
     679        VB->NextPrimitive[VB->CopyStart] = VB->Count;
     680        VB->Primitive[VB->CopyStart] = mode;
     681        ctx->Array.Flag[count] |= VERT_END_VB;
    680682
    681683         /* Transform and render.
    682           */
     684          */
    683685         gl_run_pipeline( VB );
    684         gl_reset_vb( VB );
    685 
    686         ctx->Array.Flag[count] = ctx->Array.Flags;
    687         ctx->Array.Flag[VB_START] = ctx->Array.Flags;
     686        gl_reset_vb( VB );
     687
     688        ctx->Array.Flag[count] = ctx->Array.Flags;
     689        ctx->Array.Flag[VB_START] = ctx->Array.Flags;
    688690
    689691         start += n;
     
    694696
    695697      if (relock) {
    696         ctx->CompileCVAFlag = relock;
    697         elt->pipeline_valid = 0;
     698        ctx->CompileCVAFlag = relock;
     699        elt->pipeline_valid = 0;
    698700      }
    699701   }
     
    729731 */
    730732#if 1
    731 #define DRAW_ELT(FUNC, TYPE)                            \
    732 static void FUNC( GLcontext *ctx, GLenum mode,          \
    733                   TYPE *indices, GLuint count )         \
    734 {                                                       \
    735    GLuint i,j;                                          \
    736                                                         \
    737    gl_Begin( ctx, mode );                               \
    738                                                         \
    739    for (j = 0 ; j < count ; ) {                         \
    740       struct immediate *IM = ctx->input;                \
    741       GLuint start = IM->Start;                         \
    742       GLuint nr = MIN2( VB_MAX, count - j + start );    \
    743       GLuint sf = IM->Flag[start];                      \
    744       IM->FlushElt |= IM->ArrayEltFlush;                \
    745                                                         \
    746       for (i = start ; i < nr ; i++) {                  \
    747          IM->Elt[i] = (GLuint) *indices++;              \
    748          IM->Flag[i] = VERT_ELT;                        \
    749       }                                                 \
    750                                                         \
    751       if (j == 0) IM->Flag[start] |= sf;                \
    752                                                         \
    753       IM->Count = nr;                                   \
    754       j += nr - start;                                  \
    755                                                         \
    756       if (j == count) gl_End( ctx );                    \
    757       IM->maybe_transform_vb( IM );                     \
    758    }                                                    \
     733#define DRAW_ELT(FUNC, TYPE)                            \
     734static void FUNC( GLcontext *ctx, GLenum mode,          \
     735                  TYPE *indices, GLuint count )         \
     736{                                                       \
     737   GLuint i,j;                                          \
     738                                                        \
     739   gl_Begin( ctx, mode );                               \
     740                                                        \
     741   for (j = 0 ; j < count ; ) {                         \
     742      struct immediate *IM = ctx->input;                \
     743      GLuint start = IM->Start;                         \
     744      GLuint nr = MIN2( VB_MAX, count - j + start );    \
     745      GLuint sf = IM->Flag[start];                      \
     746      IM->FlushElt |= IM->ArrayEltFlush;                \
     747                                                        \
     748      for (i = start ; i < nr ; i++) {                  \
     749         IM->Elt[i] = (GLuint) *indices++;              \
     750         IM->Flag[i] = VERT_ELT;                        \
     751      }                                                 \
     752                                                        \
     753      if (j == 0) IM->Flag[start] |= sf;                \
     754                                                        \
     755      IM->Count = nr;                                   \
     756      j += nr - start;                                  \
     757                                                        \
     758      if (j == count) gl_End( ctx );                    \
     759      IM->maybe_transform_vb( IM );                     \
     760   }                                                    \
    759761}
    760762#else
    761 #define DRAW_ELT(FUNC, TYPE)                            \
    762 static void FUNC( GLcontext *ctx, GLenum mode,          \
    763                    TYPE *indices, GLuint count )        \
    764 {                                                       \
    765   int i;                                                \
    766   glBegin(mode);                                        \
    767   for (i = 0 ; i < count ; i++)                         \
    768     glArrayElement( indices[i] );                       \
    769   glEnd();                                              \
     763#define DRAW_ELT(FUNC, TYPE)                            \
     764static void FUNC( GLcontext *ctx, GLenum mode,          \
     765                   TYPE *indices, GLuint count )        \
     766{                                                       \
     767  int i;                                                \
     768  glBegin(mode);                                        \
     769  for (i = 0 ; i < count ; i++)                         \
     770    glArrayElement( indices[i] );                       \
     771  glEnd();                                              \
    770772}
    771773#endif
    772        
     774
    773775
    774776DRAW_ELT( draw_elt_ubyte, GLubyte )
     
    779781static GLuint natural_stride[0x10] =
    780782{
    781    sizeof(GLbyte),              /* 0 */
    782    sizeof(GLubyte),             /* 1 */
    783    sizeof(GLshort),             /* 2 */
    784    sizeof(GLushort),            /* 3 */
    785    sizeof(GLint),               /* 4 */
    786    sizeof(GLuint),              /* 5 */
    787    sizeof(GLfloat),             /* 6 */
    788    2 * sizeof(GLbyte),          /* 7 */
    789    3 * sizeof(GLbyte),          /* 8 */
    790    4 * sizeof(GLbyte),          /* 9 */
    791    sizeof(GLdouble),            /* a */
    792    0,                           /* b */
    793    0,                           /* c */
    794    0,                           /* d */
    795    0,                           /* e */
    796    0                            /* f */
     783   sizeof(GLbyte),              /* 0 */
     784   sizeof(GLubyte),             /* 1 */
     785   sizeof(GLshort),             /* 2 */
     786   sizeof(GLushort),            /* 3 */
     787   sizeof(GLint),               /* 4 */
     788   sizeof(GLuint),              /* 5 */
     789   sizeof(GLfloat),             /* 6 */
     790   2 * sizeof(GLbyte),          /* 7 */
     791   3 * sizeof(GLbyte),          /* 8 */
     792   4 * sizeof(GLbyte),          /* 9 */
     793   sizeof(GLdouble),            /* a */
     794   0,                           /* b */
     795   0,                           /* c */
     796   0,                           /* d */
     797   0,                           /* e */
     798   0                            /* f */
    797799};
    798800
    799 void GLAPIENTRY glDrawElements(CTX_ARG GLenum mode, GLsizei count,
    800                                 GLenum type, const GLvoid *indices )
    801 {
    802    GLcontext *ctx;
     801
     802void
     803_mesa_DrawElements(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices )
     804{
     805   GET_CURRENT_CONTEXT(ctx);
    803806   struct gl_cva *cva;
    804 
    805    GET_CONTEXT;
    806    CHECK_CONTEXT;
    807    ctx = CC;
    808807
    809808   cva = &ctx->CVA;
     
    812811   if (count <= 0) {
    813812      if (count < 0)
    814         gl_error( ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
     813        gl_error( ctx, GL_INVALID_VALUE, "glDrawElements(count)" );
    815814      return;
    816815   }
     
    850849
    851850      if (!cva->pre.pipeline_valid)
    852         gl_build_precalc_pipeline( ctx );
     851        gl_build_precalc_pipeline( ctx );
    853852      else if (MESA_VERBOSE & VERBOSE_PIPELINE)
    854         fprintf(stderr, ": dont rebuild\n");
     853        fprintf(stderr, ": dont rebuild\n");
    855854
    856855      gl_cva_force_precalc( ctx );
     
    859858       */
    860859      if (ctx->CVA.pre.ops & PIPE_OP_RENDER) {
    861         ctx->Array.NewArrayState |= VERT_ELT;
    862         ctx->Array.Summary &= ~VERT_ELT;
    863         ctx->Array.Flags &= ~VERT_ELT;
    864         return;
     860        ctx->Array.NewArrayState |= VERT_ELT;
     861        ctx->Array.Summary &= ~VERT_ELT;
     862        ctx->Array.Flags &= ~VERT_ELT;
     863        return;
    865864      }
    866865
    867866      if ( (MESA_VERBOSE&VERBOSE_VARRAY) )
    868         printf("using immediate\n");
     867        printf("using immediate\n");
    869868   }
    870869
     
    877876      GLubyte *ub_indices = (GLubyte *) indices;
    878877      if (ctx->Array.Summary & VERT_OBJ_ANY) {
    879         draw_elt_ubyte( ctx, mode, ub_indices, count );
     878        draw_elt_ubyte( ctx, mode, ub_indices, count );
    880879      } else {
    881         gl_ArrayElement( ctx, (GLuint) ub_indices[count-1] );
     880        gl_ArrayElement( ctx, (GLuint) ub_indices[count-1] );
    882881      }
    883882   }
     
    887886      GLushort *us_indices = (GLushort *) indices;
    888887      if (ctx->Array.Summary & VERT_OBJ_ANY) {
    889         draw_elt_ushort( ctx, mode, us_indices, count );
     888        draw_elt_ushort( ctx, mode, us_indices, count );
    890889      } else {
    891         gl_ArrayElement( ctx, (GLuint) us_indices[count-1] );
     890        gl_ArrayElement( ctx, (GLuint) us_indices[count-1] );
    892891      }
    893892   }
     
    897896      GLuint *ui_indices = (GLuint *) indices;
    898897      if (ctx->Array.Summary & VERT_OBJ_ANY) {
    899         draw_elt_uint( ctx, mode, ui_indices, count );
     898        draw_elt_uint( ctx, mode, ui_indices, count );
    900899      } else {
    901         gl_ArrayElement( ctx, ui_indices[count-1] );
     900        gl_ArrayElement( ctx, ui_indices[count-1] );
    902901      }
    903902   }
     
    916915
    917916
    918 void GLAPIENTRY glInterleavedArrays(CTX_ARG GLenum format, GLsizei stride,
    919                                     const GLvoid *pointer )
    920 {
    921    GLcontext *ctx;
     917void
     918_mesa_InterleavedArrays(GLenum format, GLsizei stride, const GLvoid *pointer )
     919{
     920   GET_CURRENT_CONTEXT(ctx);
    922921   GLboolean tflag, cflag, nflag;  /* enable/disable flags */
    923922   GLint tcomps, ccomps, vcomps;   /* components per texcoord, color, vertex */
     
    928927   GLint c, f;
    929928   GLint coordUnitSave;
    930 
    931    GET_CONTEXT;
    932    CHECK_CONTEXT;
    933    ctx = CC;
    934 
    935929
    936930   f = sizeof(GLfloat);
     
    10571051   }
    10581052
    1059    gl_DisableClientState( ctx, GL_EDGE_FLAG_ARRAY );
    1060    gl_DisableClientState( ctx, GL_INDEX_ARRAY );
     1053   _mesa_DisableClientState( GL_EDGE_FLAG_ARRAY );
     1054   _mesa_DisableClientState( GL_INDEX_ARRAY );
    10611055
    10621056   /* Texcoords */
     
    10661060      GLint factor = ctx->Array.TexCoordInterleaveFactor;
    10671061      for (i = 0; i < factor; i++) {
    1068          gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + i) );
    1069          gl_EnableClientState( ctx, GL_TEXTURE_COORD_ARRAY );
    1070          glTexCoordPointer(CTX_PRM tcomps, GL_FLOAT, stride,
     1062         _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
     1063         _mesa_EnableClientState( GL_TEXTURE_COORD_ARRAY );
     1064         glTexCoordPointer( tcomps, GL_FLOAT, stride,
    10711065                             (GLubyte *) pointer + i * coffset );
    10721066      }
    10731067      for (i = factor; i < ctx->Const.MaxTextureUnits; i++) {
    1074          gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + i) );
    1075          gl_DisableClientState( ctx, GL_TEXTURE_COORD_ARRAY );
     1068         _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
     1069         _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
    10761070      }
    10771071   }
     
    10791073      GLint i;
    10801074      for (i = 0; i < ctx->Const.MaxTextureUnits; i++) {
    1081          gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + i) );
    1082          gl_DisableClientState( ctx, GL_TEXTURE_COORD_ARRAY );
     1075         _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + i) );
     1076         _mesa_DisableClientState( GL_TEXTURE_COORD_ARRAY );
    10831077      }
    10841078   }
    10851079   /* Restore texture coordinate unit index */
    1086    gl_ClientActiveTexture( ctx, (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) );
     1080   _mesa_ClientActiveTextureARB( (GLenum) (GL_TEXTURE0_ARB + coordUnitSave) );
    10871081
    10881082
    10891083   /* Color */
    10901084   if (cflag) {
    1091       gl_EnableClientState( ctx, GL_COLOR_ARRAY );
    1092       glColorPointer(CTX_PRM ccomps, ctype, stride,
     1085      _mesa_EnableClientState( GL_COLOR_ARRAY );
     1086      glColorPointer( ccomps, ctype, stride,
    10931087                       (GLubyte*) pointer + coffset );
    10941088   }
    10951089   else {
    1096       gl_DisableClientState( ctx, GL_COLOR_ARRAY );
     1090      _mesa_DisableClientState( GL_COLOR_ARRAY );
    10971091   }
    10981092
     
    11001094   /* Normals */
    11011095   if (nflag) {
    1102       gl_EnableClientState( ctx, GL_NORMAL_ARRAY );
    1103       glNormalPointer(CTX_PRM GL_FLOAT, stride,
     1096      _mesa_EnableClientState( GL_NORMAL_ARRAY );
     1097      glNormalPointer( GL_FLOAT, stride,
    11041098                        (GLubyte*) pointer + noffset );
    11051099   }
    11061100   else {
    1107       gl_DisableClientState( ctx, GL_NORMAL_ARRAY );
    1108    }
    1109 
    1110    gl_EnableClientState( ctx, GL_VERTEX_ARRAY );
    1111    glVertexPointer(CTX_PRM vcomps, GL_FLOAT, stride,
     1101      _mesa_DisableClientState( GL_NORMAL_ARRAY );
     1102   }
     1103
     1104   _mesa_EnableClientState( GL_VERTEX_ARRAY );
     1105   glVertexPointer( vcomps, GL_FLOAT, stride,
    11121106                     (GLubyte *) pointer + voffset );
    11131107}
     
    11151109
    11161110
    1117 void GLAPIENTRY glDrawRangeElements(CTX_ARG GLenum mode, GLuint start,
    1118                                      GLuint end, GLsizei count,
    1119                                      GLenum type, const GLvoid *indices )
    1120 {
    1121    GLcontext *ctx;
    1122    GET_CONTEXT;
    1123    CHECK_CONTEXT;
    1124    ctx = CC;
     1111void
     1112_mesa_DrawRangeElements(GLenum mode, GLuint start,
     1113                        GLuint end, GLsizei count,
     1114                        GLenum type, const GLvoid *indices)
     1115{
     1116   GET_CURRENT_CONTEXT(ctx);
    11251117
    11261118   if (end < start) {
     
    11291121   }
    11301122
     1123#if 0
     1124   /*
     1125    * XXX something in locked arrays is broken!  If start = 0,
     1126    * end = 1 and count = 2 we'll take the LockArrays path and
     1127    * get incorrect results.  See Scott McMillan's bug of 3 Jan 2000.
     1128    * For now, don't use locked arrays.
     1129    */
    11311130   if (!ctx->Array.LockCount && 2*count > (GLint) 3*(end-start)) {
    1132       glLockArraysEXT(CTX_PRM start, end );
    1133       glDrawElements(CTX_PRM mode, count, type, indices );
    1134       glUnlockArraysEXT(CTX_VPRM );
     1131      glLockArraysEXT( start, end );
     1132      glDrawElements( mode, count, type, indices );
     1133      glUnlockArraysEXT();
    11351134   } else {
    1136       glDrawElements(CTX_PRM mode, count, type, indices );
    1137    }
     1135      glDrawElements( mode, count, type, indices );
     1136   }
     1137#else
     1138   glDrawElements( mode, count, type, indices );
     1139#endif
    11381140}
    11391141
     
    11431145{
    11441146   static GLuint sz_flags[5] = { 0,
    1145                                 0,
    1146                                 VERT_OBJ_2,
    1147                                 VERT_OBJ_23,
    1148                                 VERT_OBJ_234 };
     1147                                0,
     1148                                VERT_OBJ_2,
     1149                                VERT_OBJ_23,
     1150                                VERT_OBJ_234 };
    11491151
    11501152   static GLuint tc_flags[5] = { 0,
    1151                                 VERT_TEX0_1,
    1152                                 VERT_TEX0_12,
    1153                                 VERT_TEX0_123,
    1154                                 VERT_TEX0_1234 };
     1153                                VERT_TEX0_1,
     1154                                VERT_TEX0_12,
     1155                                VERT_TEX0_123,
     1156                                VERT_TEX0_1234 };
    11551157
    11561158   ctx->Array.Flags = 0;
Note: See TracChangeset for help on using the changeset viewer.