memset(&examined, 0, sizeof(examined));
prev = *state;
- for (i = 0; i < Elements(atoms); i++) {
+ for (i = 0; i < ARRAY_SIZE(atoms); i++) {
const struct st_tracked_state *atom = atoms[i];
struct st_state_flags generated;
}
else {
- for (i = 0; i < Elements(atoms); i++) {
+ for (i = 0; i < ARRAY_SIZE(atoms); i++) {
if (check_state(state, &atoms[i]->dirty))
atoms[i]->update( st );
}
GLuint ic = 0;
const GLuint shaderIndex = write_depth * 2 + write_stencil;
- assert(shaderIndex < Elements(st->drawpix.shaders));
+ assert(shaderIndex < ARRAY_SIZE(st->drawpix.shaders));
if (st->drawpix.shaders[shaderIndex]) {
/* already have the proper shader */
{
GLuint i;
- for (i = 0; i < Elements(st->drawpix.shaders); i++) {
+ for (i = 0; i < ARRAY_SIZE(st->drawpix.shaders); i++) {
if (st->drawpix.shaders[i])
_mesa_reference_fragprog(st->ctx, &st->drawpix.shaders[i], NULL);
}
rs->stage.destroy = rastpos_destroy;
rs->ctx = ctx;
- for (i = 0; i < Elements(rs->array); i++) {
+ for (i = 0; i < ARRAY_SIZE(rs->array); i++) {
rs->array[i].Size = 4;
rs->array[i].Type = GL_FLOAT;
rs->array[i].Format = GL_RGBA;
pipe_so_target_reference(&sobj->targets[i], NULL);
}
- for (i = 0; i < Elements(sobj->base.Buffers); i++) {
+ for (i = 0; i < ARRAY_SIZE(sobj->base.Buffers); i++) {
_mesa_reference_buffer_object(ctx, &sobj->base.Buffers[i], NULL);
}
unsigned i, max_num_targets;
unsigned offsets[PIPE_MAX_SO_BUFFERS] = {0};
- max_num_targets = MIN2(Elements(sobj->base.Buffers),
- Elements(sobj->targets));
+ max_num_targets = MIN2(ARRAY_SIZE(sobj->base.Buffers),
+ ARRAY_SIZE(sobj->targets));
/* Convert the transform feedback state into the gallium representation. */
for (i = 0; i < max_num_targets; i++) {
st_transform_feedback_object(obj);
unsigned i;
- for (i = 0; i < Elements(sobj->targets); i++) {
+ for (i = 0; i < ARRAY_SIZE(sobj->targets); i++) {
if (sobj->targets[i]) {
return sobj->targets[i];
}
st_destroy_drawpix(st);
st_destroy_drawtex(st);
- for (shader = 0; shader < Elements(st->state.sampler_views); shader++) {
- for (i = 0; i < Elements(st->state.sampler_views[0]); i++) {
+ for (shader = 0; shader < ARRAY_SIZE(st->state.sampler_views); shader++) {
+ for (i = 0; i < ARRAY_SIZE(st->state.sampler_views[0]); i++) {
pipe_sampler_view_release(st->pipe,
&st->state.sampler_views[shader][i]);
}
/* Vertex element objects used for drawing rectangles for glBitmap,
* glDrawPixels, glClear, etc.
*/
- for (i = 0; i < Elements(st->velems_util_draw); i++) {
+ for (i = 0; i < ARRAY_SIZE(st->velems_util_draw); i++) {
memset(&st->velems_util_draw[i], 0, sizeof(struct pipe_vertex_element));
st->velems_util_draw[i].src_offset = i * 4 * sizeof(float);
st->velems_util_draw[i].instance_divisor = 0;
GLboolean *extension_table = (GLboolean *) extensions;
unsigned i;
int j;
- int num_formats = Elements(mapping->format);
- int num_ext = Elements(mapping->extension_offset);
+ int num_formats = ARRAY_SIZE(mapping->format);
+ int num_ext = ARRAY_SIZE(mapping->extension_offset);
for (i = 0; i < num_mappings; i++) {
int num_supported = 0;
extensions->OES_draw_texture = GL_TRUE;
/* Expose the extensions which directly correspond to gallium caps. */
- for (i = 0; i < Elements(cap_mapping); i++) {
+ for (i = 0; i < ARRAY_SIZE(cap_mapping); i++) {
if (screen->get_param(screen, cap_mapping[i].cap)) {
extension_table[cap_mapping[i].extension_offset] = GL_TRUE;
}
/* Expose the extensions which directly correspond to gallium formats. */
init_format_extensions(screen, extensions, rendertarget_mapping,
- Elements(rendertarget_mapping), PIPE_TEXTURE_2D,
+ ARRAY_SIZE(rendertarget_mapping), PIPE_TEXTURE_2D,
PIPE_BIND_RENDER_TARGET | PIPE_BIND_SAMPLER_VIEW);
init_format_extensions(screen, extensions, depthstencil_mapping,
- Elements(depthstencil_mapping), PIPE_TEXTURE_2D,
+ ARRAY_SIZE(depthstencil_mapping), PIPE_TEXTURE_2D,
PIPE_BIND_DEPTH_STENCIL | PIPE_BIND_SAMPLER_VIEW);
init_format_extensions(screen, extensions, texture_mapping,
- Elements(texture_mapping), PIPE_TEXTURE_2D,
+ ARRAY_SIZE(texture_mapping), PIPE_TEXTURE_2D,
PIPE_BIND_SAMPLER_VIEW);
init_format_extensions(screen, extensions, vertex_mapping,
- Elements(vertex_mapping), PIPE_BUFFER,
+ ARRAY_SIZE(vertex_mapping), PIPE_BUFFER,
PIPE_BIND_VERTEX_BUFFER);
/* Figure out GLSL support. */
};
consts->MaxSamples =
- get_max_samples_for_formats(screen, Elements(color_formats),
+ get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats),
color_formats, 16,
PIPE_BIND_RENDER_TARGET);
consts->MaxColorTextureSamples =
- get_max_samples_for_formats(screen, Elements(color_formats),
+ get_max_samples_for_formats(screen, ARRAY_SIZE(color_formats),
color_formats, consts->MaxSamples,
PIPE_BIND_SAMPLER_VIEW);
consts->MaxDepthTextureSamples =
- get_max_samples_for_formats(screen, Elements(depth_formats),
+ get_max_samples_for_formats(screen, ARRAY_SIZE(depth_formats),
depth_formats, consts->MaxSamples,
PIPE_BIND_SAMPLER_VIEW);
consts->MaxIntegerSamples =
- get_max_samples_for_formats(screen, Elements(int_formats),
+ get_max_samples_for_formats(screen, ARRAY_SIZE(int_formats),
int_formats, consts->MaxSamples,
PIPE_BIND_SAMPLER_VIEW);
}
extensions->ARB_texture_buffer_range = GL_TRUE;
init_format_extensions(screen, extensions, tbo_rgb32,
- Elements(tbo_rgb32), PIPE_BUFFER,
+ ARRAY_SIZE(tbo_rgb32), PIPE_BUFFER,
PIPE_BIND_SAMPLER_VIEW);
}
return pf;
/* search table for internalFormat */
- for (i = 0; i < Elements(format_map); i++) {
+ for (i = 0; i < ARRAY_SIZE(format_map); i++) {
const struct format_mapping *mapping = &format_map[i];
for (j = 0; mapping->glFormats[j]; j++) {
if (mapping->glFormats[j] == internalFormat) {
glsl_to_tgsi_visitor::visit(ir_expression *ir)
{
unsigned int operand;
- st_src_reg op[Elements(ir->operands)];
+ st_src_reg op[ARRAY_SIZE(ir->operands)];
st_src_reg result_src;
st_dst_reg result_dst;
/* Continuing the block, clear any channels from the write array that
* are read by this instruction.
*/
- for (unsigned i = 0; i < Elements(inst->src); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(inst->src); i++) {
if (inst->src[i].file == PROGRAM_TEMPORARY && inst->src[i].reladdr){
/* Any temporary might be read, so no dead code elimination
* across this instruction.
* If there is already an instruction in the write array for one or more
* of the channels, flag that channel write as dead.
*/
- for (unsigned i = 0; i < Elements(inst->dst); i++) {
+ for (unsigned i = 0; i < ARRAY_SIZE(inst->dst); i++) {
if (inst->dst[i].file == PROGRAM_TEMPORARY &&
!inst->dst[i].reladdr &&
!inst->saturate) {
case PROGRAM_ARRAY:
array = index >> 16;
- assert(array < Elements(t->arrays));
+ assert(array < ARRAY_SIZE(t->arrays));
if (ureg_dst_is_undef(t->arrays[array]))
t->arrays[array] = ureg_DECL_array_temporary(
else
assert(index < VARYING_SLOT_MAX);
- assert(t->outputMapping[index] < Elements(t->outputs));
+ assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
return t->outputs[t->outputMapping[index]];
return t->immediates[reg->index];
case PROGRAM_INPUT:
- assert(t->inputMapping[reg->index] < Elements(t->inputs));
+ assert(t->inputMapping[reg->index] < ARRAY_SIZE(t->inputs));
return t->inputs[t->inputMapping[reg->index]];
case PROGRAM_OUTPUT:
- assert(t->outputMapping[reg->index] < Elements(t->outputs));
+ assert(t->outputMapping[reg->index] < ARRAY_SIZE(t->outputs));
return ureg_src(t->outputs[t->outputMapping[reg->index]]); /* not needed? */
case PROGRAM_ADDRESS:
return ureg_src(t->address[reg->index]);
case PROGRAM_SYSTEM_VALUE:
- assert(reg->index < (int) Elements(t->systemValues));
+ assert(reg->index < (int) ARRAY_SIZE(t->systemValues));
return t->systemValues[reg->index];
default:
array = in_offset->index >> 16;
assert(array >= 0);
- assert(array < (int) Elements(t->arrays));
+ assert(array < (int) ARRAY_SIZE(t->arrays));
dst = t->arrays[array];
offset.File = dst.File;
unsigned i;
enum pipe_error ret = PIPE_OK;
- assert(numInputs <= Elements(t->inputs));
- assert(numOutputs <= Elements(t->outputs));
+ assert(numInputs <= ARRAY_SIZE(t->inputs));
+ assert(numOutputs <= ARRAY_SIZE(t->outputs));
assert(_mesa_sysval_to_semantic[SYSTEM_VALUE_FRONT_FACE] ==
TGSI_SEMANTIC_FACE);
else
assert(index < VARYING_SLOT_MAX);
- assert(t->outputMapping[index] < Elements(t->outputs));
+ assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
return t->outputs[t->outputMapping[index]];
case PROGRAM_TEMPORARY:
assert(index >= 0);
- assert(index < Elements(t->temps));
+ assert(index < ARRAY_SIZE(t->temps));
if (ureg_dst_is_undef(t->temps[index]))
t->temps[index] = ureg_DECL_temporary( t->ureg );
return ureg_src(t->temps[index]);
return t->constants[index];
case PROGRAM_INPUT:
- assert(t->inputMapping[index] < Elements(t->inputs));
+ assert(t->inputMapping[index] < ARRAY_SIZE(t->inputs));
return t->inputs[t->inputMapping[index]];
case PROGRAM_OUTPUT:
- assert(t->outputMapping[index] < Elements(t->outputs));
+ assert(t->outputMapping[index] < ARRAY_SIZE(t->outputs));
return ureg_src(t->outputs[t->outputMapping[index]]); /* not needed? */
case PROGRAM_ADDRESS:
return ureg_src(t->address[index]);
case PROGRAM_SYSTEM_VALUE:
- assert(index < Elements(t->systemValues));
+ assert(index < ARRAY_SIZE(t->systemValues));
return t->systemValues[index];
default:
unsigned i;
enum pipe_error ret = PIPE_OK;
- assert(numInputs <= Elements(t->inputs));
- assert(numOutputs <= Elements(t->outputs));
+ assert(numInputs <= ARRAY_SIZE(t->inputs));
+ assert(numOutputs <= ARRAY_SIZE(t->outputs));
t = &translate;
memset(t, 0, sizeof *t);
/* fall through */
case VARYING_SLOT_VAR0:
default:
- assert(slot < Elements(gs_output_semantic_name));
+ assert(slot < ARRAY_SIZE(gs_output_semantic_name));
assert(attr >= VARYING_SLOT_VAR0);
gs_output_semantic_name[slot] = TGSI_SEMANTIC_GENERIC;
gs_output_semantic_index[slot] =
destroy_program_variants(st, shProg->Shaders[i]->Program);
}
- for (i = 0; i < Elements(shProg->_LinkedShaders); i++) {
+ for (i = 0; i < ARRAY_SIZE(shProg->_LinkedShaders); i++) {
if (shProg->_LinkedShaders[i])
destroy_program_variants(st, shProg->_LinkedShaders[i]->Program);
}