{
GLuint i;
- for (i = 0; i < Elements(obj->VertexBinding); i++)
+ for (i = 0; i < ARRAY_SIZE(obj->VertexBinding); i++)
_mesa_reference_buffer_object(ctx, &obj->VertexBinding[i].BufferObj, NULL);
- for (i = 0; i < Elements(obj->_VertexAttrib); i++)
+ for (i = 0; i < ARRAY_SIZE(obj->_VertexAttrib); i++)
_mesa_reference_buffer_object(ctx, &obj->_VertexAttrib[i].BufferObj, NULL);
}
obj->RefCount = 1;
/* Init the individual arrays */
- for (i = 0; i < Elements(obj->VertexAttrib); i++) {
+ for (i = 0; i < ARRAY_SIZE(obj->VertexAttrib); i++) {
switch (i) {
case VERT_ATTRIB_WEIGHT:
init_array(ctx, obj, VERT_ATTRIB_WEIGHT, 1, GL_FLOAT);
/* In theory must be the same anyway, but on recreate make sure it matches */
dest->ARBsemantics = src->ARBsemantics;
- for (i = 0; i < Elements(src->VertexAttrib); i++) {
+ for (i = 0; i < ARRAY_SIZE(src->VertexAttrib); i++) {
_mesa_copy_client_array(ctx, &dest->_VertexAttrib[i], &src->_VertexAttrib[i]);
_mesa_copy_vertex_attrib_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]);
_mesa_copy_vertex_buffer_binding(ctx, &dest->VertexBinding[i], &src->VertexBinding[i]);
ctx->Color.AlphaFunc = GL_ALWAYS;
ctx->Color.AlphaRef = 0;
ctx->Color.BlendEnabled = 0x0;
- for (i = 0; i < Elements(ctx->Color.Blend); i++) {
+ for (i = 0; i < ARRAY_SIZE(ctx->Color.Blend); i++) {
ctx->Color.Blend[i].SrcRGB = GL_ONE;
ctx->Color.Blend[i].DstRGB = GL_ZERO;
ctx->Color.Blend[i].SrcA = GL_ONE;
const struct gl_renderbuffer *rb)
{
GLuint i;
- for (i = 0; i < Elements(fb->Attachment); i++) {
+ for (i = 0; i < ARRAY_SIZE(fb->Attachment); i++) {
if (fb->Attachment[i].Renderbuffer == rb)
return &fb->Attachment[i];
}
_mesa_buffer_unmap_all_mappings(ctx, bufObj);
/* unbind any vertex pointers bound to this buffer */
- for (j = 0; j < Elements(vao->VertexBinding); j++) {
+ for (j = 0; j < ARRAY_SIZE(vao->VertexBinding); j++) {
unbind(ctx, &vao->VertexBinding[j].BufferObj, bufObj);
}
GLuint i;
/* Init all to (0,0,0,1) */
- for (i = 0; i < Elements(ctx->Current.Attrib); i++) {
+ for (i = 0; i < ARRAY_SIZE(ctx->Current.Attrib); i++) {
ASSIGN_4V( ctx->Current.Attrib[i], 0.0, 0.0, 0.0, 1.0 );
}
{ GL_TEXTURE_EXTERNAL_OES, "GL_TEXTURE_EXTERNAL_OES" }
};
GLuint i;
- STATIC_ASSERT(Elements(tex_targets) == NUM_TEXTURE_TARGETS);
- for (i = 0; i < Elements(tex_targets); i++) {
+ STATIC_ASSERT(ARRAY_SIZE(tex_targets) == NUM_TEXTURE_TARGETS);
+ for (i = 0; i < ARRAY_SIZE(tex_targets); i++) {
if (tex_targets[i].target == tgt)
return tex_targets[i].name;
}
return;
MESA_VERBOSE = 0x0;
- for (i = 0; i < Elements(opts); i++) {
+ for (i = 0; i < ARRAY_SIZE(opts); i++) {
if (strstr(str, opts[i].name) || strcmp(str, "all") == 0)
MESA_VERBOSE |= opts[i].flag;
}
return;
MESA_DEBUG_FLAGS = 0x0;
- for (i = 0; i < Elements(opts); i++) {
+ for (i = 0; i < ARRAY_SIZE(opts); i++) {
if (strstr(str, opts[i].name))
MESA_DEBUG_FLAGS |= opts[i].flag;
}
{
unsigned i;
- for (i = 0; i < Elements(debug_source_enums); i++) {
+ for (i = 0; i < ARRAY_SIZE(debug_source_enums); i++) {
if (debug_source_enums[i] == e)
break;
}
{
unsigned i;
- for (i = 0; i < Elements(debug_type_enums); i++) {
+ for (i = 0; i < ARRAY_SIZE(debug_type_enums); i++) {
if (debug_type_enums[i] == e)
break;
}
{
unsigned i;
- for (i = 0; i < Elements(debug_severity_enums); i++) {
+ for (i = 0; i < ARRAY_SIZE(debug_severity_enums); i++) {
if (debug_severity_enums[i] == e)
break;
}
unsigned int i;
GLdouble converted_equation[4];
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
converted_equation[i] = (GLdouble) (equation[i]);
}
unsigned int i;
GLdouble converted_equation[4];
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
converted_equation[i] = (GLdouble) (equation[i] / 65536.0);
}
unsigned int i;
GLfloat converted_coords[5];
- for (i = 0; i < Elements(converted_coords); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_coords); i++) {
converted_coords[i] = (GLfloat) (coords[i] / 65536.0f);
}
GLdouble converted_equation[4];
_mesa_GetClipPlane(plane, converted_equation);
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
equation[i] = (GLfloat) (converted_equation[i]);
}
}
GLdouble converted_equation[4];
_mesa_GetClipPlane(plane, converted_equation);
- for (i = 0; i < Elements(converted_equation); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_equation); i++) {
equation[i] = (GLfixed) (converted_equation[i] * 65536);
}
}
unsigned int i;
GLfloat converted_m[16];
- for (i = 0; i < Elements(converted_m); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_m); i++) {
converted_m[i] = (GLfloat) (m[i] / 65536.0f);
}
unsigned int i;
GLfloat converted_m[16];
- for (i = 0; i < Elements(converted_m); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_m); i++) {
converted_m[i] = (GLfloat) (m[i] / 65536.0f);
}
unsigned int i;
GLfloat converted_params[4];
- for (i = 0; i < Elements(converted_params); i++) {
+ for (i = 0; i < ARRAY_SIZE(converted_params); i++) {
converted_params[i] = (GLfloat) (params[i] / 65536.0f);
}
{
GLuint i;
- STATIC_ASSERT(Elements(format_info) == MESA_FORMAT_COUNT);
+ STATIC_ASSERT(ARRAY_SIZE(format_info) == MESA_FORMAT_COUNT);
for (i = 0; i < MESA_FORMAT_COUNT; i++) {
const struct gl_format_info *info = _mesa_get_format_info(i);
};
const char *api_name;
- api_name = api < Elements(api_names) ? api_names[api] : "N/A";
+ api_name = api < ARRAY_SIZE(api_names) ? api_names[api] : "N/A";
count = 0;
- mask = Elements(table(api)) - 1;
+ mask = ARRAY_SIZE(table(api)) - 1;
memset(collisions, 0, sizeof collisions);
- for (i = 0; i < Elements(table(api)); i++) {
+ for (i = 0; i < ARRAY_SIZE(table(api)); i++) {
if (!table(api)[i])
continue;
count++;
}
printf("number of enums for %s: %d (total %ld)\n",
- api_name, count, Elements(values));
- for (i = 0; i < Elements(collisions) - 1; i++)
+ api_name, count, ARRAY_SIZE(values));
+ for (i = 0; i < ARRAY_SIZE(collisions) - 1; i++)
if (collisions[i] > 0)
printf(" %d enums with %d %scollisions\n",
collisions[i], i, i == 10 ? "or more " : "");
* value since it's compatible with GLES2 its entry in table_set[] is at the
* end.
*/
- STATIC_ASSERT(Elements(table_set) == API_OPENGL_LAST + 2);
+ STATIC_ASSERT(ARRAY_SIZE(table_set) == API_OPENGL_LAST + 2);
if (_mesa_is_gles3(ctx)) {
api = API_OPENGL_LAST + 1;
}
- mask = Elements(table(api)) - 1;
+ mask = ARRAY_SIZE(table(api)) - 1;
hash = (pname * prime_factor);
while (1) {
int idx = table(api)[hash & mask];
return;
}
#endif
- assert(ctx->Texture.CurrentUnit < Elements(ctx->TextureMatrixStack));
+ assert(ctx->Texture.CurrentUnit < ARRAY_SIZE(ctx->TextureMatrixStack));
ctx->CurrentStack = &ctx->TextureMatrixStack[ctx->Texture.CurrentUnit];
break;
case GL_MATRIX0_ARB:
_NEW_MODELVIEW);
init_matrix_stack(&ctx->ProjectionMatrixStack, MAX_PROJECTION_STACK_DEPTH,
_NEW_PROJECTION);
- for (i = 0; i < Elements(ctx->TextureMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++)
init_matrix_stack(&ctx->TextureMatrixStack[i], MAX_TEXTURE_STACK_DEPTH,
_NEW_TEXTURE_MATRIX);
- for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
init_matrix_stack(&ctx->ProgramMatrixStack[i],
MAX_PROGRAM_MATRIX_STACK_DEPTH, _NEW_TRACK_MATRIX);
ctx->CurrentStack = &ctx->ModelviewMatrixStack;
free_matrix_stack(&ctx->ModelviewMatrixStack);
free_matrix_stack(&ctx->ProjectionMatrixStack);
- for (i = 0; i < Elements(ctx->TextureMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->TextureMatrixStack); i++)
free_matrix_stack(&ctx->TextureMatrixStack[i]);
- for (i = 0; i < Elements(ctx->ProgramMatrixStack); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->ProgramMatrixStack); i++)
free_matrix_stack(&ctx->ProgramMatrixStack[i]);
/* combined Modelview*Projection matrix */
_math_matrix_dtr( &ctx->_ModelProjectMatrix );
ctx->Point.SpriteRMode = GL_ZERO; /* GL_NV_point_sprite (only!) */
ctx->Point.SpriteOrigin = GL_UPPER_LEFT; /* GL_ARB_point_sprite */
- for (i = 0; i < Elements(ctx->Point.CoordReplace); i++) {
+ for (i = 0; i < ARRAY_SIZE(ctx->Point.CoordReplace); i++) {
ctx->Point.CoordReplace[i] = GL_FALSE; /* GL_ARB/NV_point_sprite */
}
}
{
GLuint texSet;
for (texSet = 0; texSet < ctx->Const.MaxTextureCoordUnits; texSet++) {
- assert(texSet < Elements(ctx->Current.RasterTexCoords));
+ assert(texSet < ARRAY_SIZE(ctx->Current.RasterTexCoords));
COPY_4FV( ctx->Current.RasterTexCoords[texSet],
ctx->Current.Attrib[VERT_ATTRIB_TEX0 + texSet] );
}
ctx->Current.RasterDistance = 0.0;
ASSIGN_4V( ctx->Current.RasterColor, 1.0, 1.0, 1.0, 1.0 );
ASSIGN_4V( ctx->Current.RasterSecondaryColor, 0.0, 0.0, 0.0, 1.0 );
- for (i = 0; i < Elements(ctx->Current.RasterTexCoords); i++)
+ for (i = 0; i < ARRAY_SIZE(ctx->Current.RasterTexCoords); i++)
ASSIGN_4V( ctx->Current.RasterTexCoords[i], 0.0, 0.0, 0.0, 1.0 );
ctx->Current.RasterPosValid = GL_TRUE;
}
const char *
_mesa_get_function_spec(GLint func_index)
{
- if (func_index < Elements(_mesa_function_pool))
+ if (func_index < ARRAY_SIZE(_mesa_function_pool))
return _mesa_function_pool + func_index;
else
return NULL;
GL_TEXTURE_2D,
GL_TEXTURE_1D
};
- STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS);
+ STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
shared->DefaultTex[i] = ctx->Driver.NewTextureObject(ctx, 0, targets[i]);
}
* NUM_TEXTURE_TARGETS should match number of terms above, except there's no
* proxy for GL_TEXTURE_BUFFER and GL_TEXTURE_EXTERNAL_OES.
*/
- STATIC_ASSERT(NUM_TEXTURE_TARGETS == Elements(targets) + 2);
+ STATIC_ASSERT(NUM_TEXTURE_TARGETS == ARRAY_SIZE(targets) + 2);
- for (i = 0; i < Elements(targets); ++i)
+ for (i = 0; i < ARRAY_SIZE(targets); ++i)
if (target == targets[i])
return GL_TRUE;
return GL_FALSE;
k = _mesa_max_tex_unit(ctx);
- assert(k <= Elements(ctx->Texture.Unit));
+ assert(k <= ARRAY_SIZE(ctx->Texture.Unit));
if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
_mesa_debug(ctx, "glActiveTexture %s\n",
ctx->Texture._TexMatEnabled = 0x0;
for (u = 0; u < ctx->Const.MaxTextureCoordUnits; u++) {
- assert(u < Elements(ctx->TextureMatrixStack));
+ assert(u < ARRAY_SIZE(ctx->TextureMatrixStack));
if (_math_matrix_is_dirty(ctx->TextureMatrixStack[u].Top)) {
_math_matrix_analyse( ctx->TextureMatrixStack[u].Top );
ctx->Texture._GenFlags |= texUnit->_GenFlags;
}
- assert(unit < Elements(ctx->TextureMatrixStack));
+ assert(unit < ARRAY_SIZE(ctx->TextureMatrixStack));
if (ctx->TextureMatrixStack[unit].Top->type != MATRIX_IDENTITY)
ctx->Texture._TexMatEnabled |= ENABLE_TEXMAT(unit);
}
};
GLint tgt;
- STATIC_ASSERT(Elements(targets) == NUM_TEXTURE_TARGETS);
+ STATIC_ASSERT(ARRAY_SIZE(targets) == NUM_TEXTURE_TARGETS);
assert(targets[TEXTURE_2D_INDEX] == GL_TEXTURE_2D);
assert(targets[TEXTURE_CUBE_INDEX] == GL_TEXTURE_CUBE_MAP);
*/
ctx->Texture.CubeMapSeamless = ctx->API == API_OPENGLES2;
- for (u = 0; u < Elements(ctx->Texture.Unit); u++)
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++)
init_texture_unit(ctx, u);
/* After we're done initializing the context's texture state the default
GLuint u, tgt;
/* unreference current textures */
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
/* The _Current texture could account for another reference */
_mesa_reference_texobj(&ctx->Texture.Unit[u]._Current, NULL);
/* GL_ARB_texture_buffer_object */
_mesa_reference_buffer_object(ctx, &ctx->Texture.BufferObject, NULL);
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
_mesa_reference_sampler_object(ctx, &ctx->Texture.Unit[u].Sampler, NULL);
}
}
{
GLuint u, tex;
- for (u = 0; u < Elements(ctx->Texture.Unit); u++) {
+ for (u = 0; u < ARRAY_SIZE(ctx->Texture.Unit); u++) {
struct gl_texture_unit *texUnit = &ctx->Texture.Unit[u];
for (tex = 0; tex < NUM_TEXTURE_TARGETS; tex++) {
_mesa_reference_texobj(&texUnit->CurrentTex[tex],
static inline struct gl_texture_unit *
_mesa_get_tex_unit(struct gl_context *ctx, GLuint unit)
{
- assert(unit < Elements(ctx->Texture.Unit));
+ assert(unit < ARRAY_SIZE(ctx->Texture.Unit));
return &(ctx->Texture.Unit[unit]);
}
GLint level;
GLuint face;
- for (level = 0; level < Elements(texObj->Image[0]); level++) {
+ for (level = 0; level < ARRAY_SIZE(texObj->Image[0]); level++) {
for (face = 0; face < numFaces; face++) {
struct gl_texture_image *texImage =
get_tex_image(ctx, texObj, face, level);
{
GLuint i;
- for (i = 0; i < Elements(obj->Buffers); i++) {
+ for (i = 0; i < ARRAY_SIZE(obj->Buffers); i++) {
_mesa_reference_buffer_object(ctx, &obj->Buffers[i], NULL);
}
* been modified.
*/
bool changed = false;
- for (unsigned j = 0; j < Elements(prog->SamplerUnits); j++) {
+ for (unsigned j = 0; j < ARRAY_SIZE(prog->SamplerUnits); j++) {
if ((sh->active_samplers & (1U << j)) != 0
&& (prog->SamplerUnits[j] != sh->SamplerUnits[j])) {
changed = true;
if (prog->SamplersUsed & (1 << s)) {
GLuint unit = shader->SamplerUnits[s];
GLuint tgt = shader->SamplerTargets[s];
- assert(unit < Elements(prog->TexturesUsed));
+ assert(unit < ARRAY_SIZE(prog->TexturesUsed));
assert(tgt < NUM_TEXTURE_TARGETS);
/* The types of the samplers associated with a particular texture
vao = ctx->Array.VAO;
- assert(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
if (!vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
/* was disabled, now being enabled */
vao = ctx->Array.VAO;
- assert(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
if (vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Enabled) {
/* was enabled, now being disabled */
return 0;
}
- assert(VERT_ATTRIB_GENERIC(index) < Elements(vao->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(vao->VertexAttrib));
array = &vao->VertexAttrib[VERT_ATTRIB_GENERIC(index)];
return NULL;
}
- assert(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
FLUSH_CURRENT(ctx, 0);
return ctx->Current.Attrib[VERT_ATTRIB_GENERIC(index)];
return;
}
- assert(VERT_ATTRIB_GENERIC(index) < Elements(ctx->Array.VAO->VertexAttrib));
+ assert(VERT_ATTRIB_GENERIC(index) < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
*pointer = (GLvoid *) ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_GENERIC(index)].Ptr;
}
return;
}
- assert(genericIndex < Elements(ctx->Array.VAO->VertexAttrib));
+ assert(genericIndex < ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
/* The ARB_vertex_attrib_binding spec says:
*
}
assert(VERT_ATTRIB_GENERIC(attribIndex) <
- Elements(ctx->Array.VAO->VertexAttrib));
+ ARRAY_SIZE(ctx->Array.VAO->VertexAttrib));
vertex_attrib_binding(ctx, VERT_ATTRIB_GENERIC(attribIndex),
VERT_ATTRIB_GENERIC(bindingIndex));