~ubuntu-branches/ubuntu/precise/mesa/precise-updates

« back to all changes in this revision

Viewing changes to src/mesa/main/arrayobj.c

  • Committer: Package Import Robot
  • Author(s): Robert Hooker
  • Date: 2012-02-02 12:05:48 UTC
  • mfrom: (1.7.1) (3.3.27 sid)
  • Revision ID: package-import@ubuntu.com-20120202120548-nvkma85jq0h4coix
Tags: 8.0~rc2-0ubuntu4
Drop drisearchdir handling, it is no longer needed with multiarch
and dri-alternates being removed.

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
#include "imports.h"
46
46
#include "context.h"
47
47
#include "mfeatures.h"
48
 
#if FEATURE_ARB_vertex_buffer_object
49
48
#include "bufferobj.h"
50
 
#endif
51
49
#include "arrayobj.h"
52
50
#include "macros.h"
53
51
#include "mtypes.h"
64
62
 * non-existent.
65
63
 */
66
64
 
67
 
static INLINE struct gl_array_object *
 
65
static inline struct gl_array_object *
68
66
lookup_arrayobj(struct gl_context *ctx, GLuint id)
69
67
{
70
68
   if (id == 0)
85
83
{
86
84
   GLuint i;
87
85
 
88
 
   _mesa_reference_buffer_object(ctx, &obj->Vertex.BufferObj, NULL);
89
 
   _mesa_reference_buffer_object(ctx, &obj->Weight.BufferObj, NULL);
90
 
   _mesa_reference_buffer_object(ctx, &obj->Normal.BufferObj, NULL);
91
 
   _mesa_reference_buffer_object(ctx, &obj->Color.BufferObj, NULL);
92
 
   _mesa_reference_buffer_object(ctx, &obj->SecondaryColor.BufferObj, NULL);
93
 
   _mesa_reference_buffer_object(ctx, &obj->FogCoord.BufferObj, NULL);
94
 
   _mesa_reference_buffer_object(ctx, &obj->Index.BufferObj, NULL);
95
 
   _mesa_reference_buffer_object(ctx, &obj->EdgeFlag.BufferObj, NULL);
96
 
 
97
 
   for (i = 0; i < Elements(obj->TexCoord); i++)
98
 
      _mesa_reference_buffer_object(ctx, &obj->TexCoord[i].BufferObj, NULL);
99
 
 
100
86
   for (i = 0; i < Elements(obj->VertexAttrib); i++)
101
 
      _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj,NULL);
102
 
 
103
 
#if FEATURE_point_size_array
104
 
   _mesa_reference_buffer_object(ctx, &obj->PointSize.BufferObj, NULL);
105
 
#endif
 
87
      _mesa_reference_buffer_object(ctx, &obj->VertexAttrib[i].BufferObj, NULL);
106
88
}
107
89
 
108
90
 
133
115
{
134
116
   (void) ctx;
135
117
   unbind_array_object_vbos(ctx, obj);
 
118
   _mesa_reference_buffer_object(ctx, &obj->ElementArrayBufferObj, NULL);
136
119
   _glthread_DESTROY_MUTEX(obj->Mutex);
137
120
   free(obj);
138
121
}
208
191
   array->Ptr = NULL;
209
192
   array->Enabled = GL_FALSE;
210
193
   array->Normalized = GL_FALSE;
 
194
   array->Integer = GL_FALSE;
211
195
   array->_ElementSize = size * _mesa_sizeof_type(type);
212
 
#if FEATURE_ARB_vertex_buffer_object
213
196
   /* Vertex array buffers */
214
197
   _mesa_reference_buffer_object(ctx, &array->BufferObj,
215
198
                                 ctx->Shared->NullBufferObj);
216
 
#endif
217
199
}
218
200
 
219
201
 
233
215
   obj->RefCount = 1;
234
216
 
235
217
   /* Init the individual arrays */
236
 
   init_array(ctx, &obj->Vertex, 4, GL_FLOAT);
237
 
   init_array(ctx, &obj->Weight, 1, GL_FLOAT);
238
 
   init_array(ctx, &obj->Normal, 3, GL_FLOAT);
239
 
   init_array(ctx, &obj->Color, 4, GL_FLOAT);
240
 
   init_array(ctx, &obj->SecondaryColor, 3, GL_FLOAT);
241
 
   init_array(ctx, &obj->FogCoord, 1, GL_FLOAT);
242
 
   init_array(ctx, &obj->Index, 1, GL_FLOAT);
243
 
   for (i = 0; i < Elements(obj->TexCoord); i++) {
244
 
      init_array(ctx, &obj->TexCoord[i], 4, GL_FLOAT);
245
 
   }
246
 
   init_array(ctx, &obj->EdgeFlag, 1, GL_BOOL);
247
218
   for (i = 0; i < Elements(obj->VertexAttrib); i++) {
248
 
      init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT);
249
 
   }
250
 
 
 
219
      switch (i) {
 
220
      case VERT_ATTRIB_WEIGHT:
 
221
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_WEIGHT], 1, GL_FLOAT);
 
222
         break;
 
223
      case VERT_ATTRIB_NORMAL:
 
224
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_NORMAL], 3, GL_FLOAT);
 
225
         break;
 
226
      case VERT_ATTRIB_COLOR1:
 
227
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_COLOR1], 3, GL_FLOAT);
 
228
         break;
 
229
      case VERT_ATTRIB_FOG:
 
230
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_FOG], 1, GL_FLOAT);
 
231
         break;
 
232
      case VERT_ATTRIB_COLOR_INDEX:
 
233
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_COLOR_INDEX], 1, GL_FLOAT);
 
234
         break;
 
235
      case VERT_ATTRIB_EDGEFLAG:
 
236
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_EDGEFLAG], 1, GL_BOOL);
 
237
         break;
251
238
#if FEATURE_point_size_array
252
 
   init_array(ctx, &obj->PointSize, 1, GL_FLOAT);
 
239
      case VERT_ATTRIB_POINT_SIZE:
 
240
         init_array(ctx, &obj->VertexAttrib[VERT_ATTRIB_POINT_SIZE], 1, GL_FLOAT);
 
241
         break;
253
242
#endif
 
243
      default:
 
244
         init_array(ctx, &obj->VertexAttrib[i], 4, GL_FLOAT);
 
245
         break;
 
246
      }
 
247
   }
 
248
 
 
249
   _mesa_reference_buffer_object(ctx, &obj->ElementArrayBufferObj,
 
250
                                 ctx->Shared->NullBufferObj);
254
251
}
255
252
 
256
253
 
289
286
static GLuint
290
287
update_min(GLuint min, struct gl_client_array *array)
291
288
{
292
 
   if (array->Enabled) {
293
 
      _mesa_update_array_max_element(array);
294
 
      return MIN2(min, array->_MaxElement);
295
 
   }
296
 
   else
297
 
      return min;
 
289
   assert(array->Enabled);
 
290
   _mesa_update_array_max_element(array);
 
291
   return MIN2(min, array->_MaxElement);
298
292
}
299
293
 
300
294
 
305
299
_mesa_update_array_object_max_element(struct gl_context *ctx,
306
300
                                      struct gl_array_object *arrayObj)
307
301
{
308
 
   GLuint i, min = ~0;
 
302
   GLbitfield64 enabled = arrayObj->_Enabled;
 
303
   GLuint min = ~0u;
309
304
 
310
 
   min = update_min(min, &arrayObj->Vertex);
311
 
   min = update_min(min, &arrayObj->Weight);
312
 
   min = update_min(min, &arrayObj->Normal);
313
 
   min = update_min(min, &arrayObj->Color);
314
 
   min = update_min(min, &arrayObj->SecondaryColor);
315
 
   min = update_min(min, &arrayObj->FogCoord);
316
 
   min = update_min(min, &arrayObj->Index);
317
 
   min = update_min(min, &arrayObj->EdgeFlag);
318
 
#if FEATURE_point_size_array
319
 
   min = update_min(min, &arrayObj->PointSize);
320
 
#endif
321
 
   for (i = 0; i < ctx->Const.MaxTextureCoordUnits; i++)
322
 
      min = update_min(min, &arrayObj->TexCoord[i]);
323
 
   for (i = 0; i < Elements(arrayObj->VertexAttrib); i++)
324
 
      min = update_min(min, &arrayObj->VertexAttrib[i]);
 
305
   while (enabled) {
 
306
      GLint attrib = _mesa_ffsll(enabled) - 1;
 
307
      enabled &= ~BITFIELD64_BIT(attrib);
 
308
      min = update_min(min, &arrayObj->VertexAttrib[attrib]);
 
309
   }
325
310
 
326
311
   /* _MaxElement is one past the last legal array element */
327
312
   arrayObj->_MaxElement = min;
374
359
            _mesa_error(ctx, GL_OUT_OF_MEMORY, "glBindVertexArrayAPPLE");
375
360
            return;
376
361
         }
 
362
 
 
363
         /* The "Interactions with APPLE_vertex_array_object" section of the
 
364
          * GL_ARB_vertex_array_object spec says:
 
365
          *
 
366
          *     "The first bind call, either BindVertexArray or
 
367
          *     BindVertexArrayAPPLE, determines the semantic of the object."
 
368
          */
 
369
         newObj->ARBsemantics = genRequired;
377
370
         save_array_object(ctx, newObj);
378
371
      }
379
372
   }
380
373
 
381
374
   ctx->NewState |= _NEW_ARRAY;
382
 
   ctx->Array.NewState |= _NEW_ARRAY_ALL;
 
375
   ctx->Array.NewState |= VERT_BIT_ALL;
383
376
   _mesa_reference_array_object(ctx, &ctx->Array.ArrayObj, newObj);
384
377
 
385
378
   /* Pass BindVertexArray call to device driver */
470
463
 * \param vboOnly Will arrays have to reside in VBOs?
471
464
 */
472
465
static void 
473
 
gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays,
474
 
                  GLboolean vboOnly)
 
466
gen_vertex_arrays(struct gl_context *ctx, GLsizei n, GLuint *arrays)
475
467
{
476
468
   GLuint first;
477
469
   GLint i;
498
490
         _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenVertexArraysAPPLE");
499
491
         return;
500
492
      }
501
 
      obj->VBOonly = vboOnly;
502
493
      save_array_object(ctx, obj);
503
494
      arrays[i] = first + i;
504
495
   }
513
504
_mesa_GenVertexArrays(GLsizei n, GLuint *arrays)
514
505
{
515
506
   GET_CURRENT_CONTEXT(ctx);
516
 
   gen_vertex_arrays(ctx, n, arrays, GL_TRUE);
 
507
   gen_vertex_arrays(ctx, n, arrays);
517
508
}
518
509
 
519
510
 
525
516
_mesa_GenVertexArraysAPPLE(GLsizei n, GLuint *arrays)
526
517
{
527
518
   GET_CURRENT_CONTEXT(ctx);
528
 
   gen_vertex_arrays(ctx, n, arrays, GL_FALSE);
 
519
   gen_vertex_arrays(ctx, n, arrays);
529
520
}
530
521
 
531
522